//! Psycho Key SDK — Rust example integration mod psychokey; use psychokey::{Client, Config}; use std::io::{self, Write}; use std::thread; use std::time::Duration; fn main() { let mut cfg = Config::new("my-app", "REPLACE_WITH_64_HEX_PRODUCT_SECRET"); cfg.version = "1.0.0".to_string(); let mut client = Client::new(cfg).expect("invalid secret"); println!("HWID: {}\n", client.hwid()); let hs = client.init(); if !hs.ok { eprintln!("Handshake failed: {} — {}", hs.code, hs.message); return; } print!("Enter license key: "); let _ = io::stdout().flush(); let mut key = String::new(); let _ = io::stdin().read_line(&mut key); let key = key.trim(); let mut res = client.auth(key); if !res.ok { eprintln!("Access denied: {} — {}", res.code, res.message); if res.code == "HWID_LIMIT" || res.code == "HWID_MISMATCH" { print!("Reset HWID? [y/N]: "); let _ = io::stdout().flush(); let mut ans = String::new(); let _ = io::stdin().read_line(&mut ans); if ans.trim().eq_ignore_ascii_case("y") { res = client.reset_hwid(key); if !res.ok { eprintln!("Reset failed: {}", res.code); return; } } else { return; } } else { return; } } println!("License accepted ({})", res.license.status); for _ in 0..3 { thread::sleep(Duration::from_secs(3)); let hb = client.heartbeat(); if !hb.ok { eprintln!("Session invalidated: {}", hb.code); return; } println!("Heartbeat OK"); } client.logout(); }