"""Psycho Key SDK — Python example integration.""" import time from psychokey import Client, Config # Replace with your product values from the panel client = Client(Config( app="my-app", # Product slug api_secret="REPLACE_WITH_64_HEX_PRODUCT_SECRET", # API Secret from panel version="1.0.0", )) print(f"HWID: {client.hwid()}\n") # 1. Handshake handshake = client.init() if not handshake.ok: print(f"Handshake failed: {handshake.code} — {handshake.message}") if handshake.code == "OUTDATED_VERSION": print(f"Update to {handshake.latest_version} at: {handshake.download_url}") exit(1) print("Server reachable ✓") # 2. License activation key = input("Enter license key: ").strip() res = client.auth(key) if not res.ok: print(f"Access denied: {res.code} — {res.message}") if res.code in ("HWID_LIMIT", "HWID_MISMATCH"): answer = input("Reset HWID and bind this machine? [y/N]: ") if answer.lower() == "y": reset = client.reset_hwid(key) if not reset.ok: print(f"Reset failed: {reset.code}") exit(1) res = reset print("HWID reset ✓") else: exit(1) else: exit(1) print(f"\nLicense accepted ✓") print(f" Status: {res.license.status}") if res.license.lifetime: print(f" Expires: never (lifetime)") else: print(f" Expires: {res.license.expires_at} ({res.license.days_left} days left)") print(f" HWID slots: {res.license.max_hwids}") if res.variables: print(f" Cloud variables: {len(res.variables)}") for k, v in res.variables.items(): print(f" {k} = {v}") # 3. Heartbeat loop print("\nRunning protected application...") for i in range(3): time.sleep(3) hb = client.heartbeat() if not hb.ok: print(f"Session invalidated: {hb.code} — shutting down.") exit(1) print(f"Heartbeat OK ({hb.license.seconds_left}s left)") # 4. Logout client.logout() print("Done.")