import base64 import json from datetime import datetime, date # Global flag for subscription status is_valid_subscription = False def generate_key(expiration_date_str): """Helper for you (owner) to generate keys. Run this locally to create keys for users.""" payload = {"expiration": expiration_date_str} encoded = base64.b64encode(json.dumps(payload).encode()).decode() offset_key = ''.join(chr(ord(c) ^ 42) for c in encoded) # Simple XOR obfuscation return offset_key # Example: To generate a key expiring end of October 2025 (for testing) # key = generate_key("2025-10-31") # print(f"Generated key: {key}") def validate_key(user_key): """Decode and validate the key.""" try: # Reverse obfuscation decoded_obfuscated = ''.join(chr(ord(c) ^ 42) for c in user_key) payload = json.loads(base64.b64decode(decoded_obfuscated.encode()).decode()) expiration_str = payload.get("expiration") if not expiration_str: return False, "Invalid key format." exp_date = datetime.strptime(expiration_str, "%Y-%m-%d").date() current_date = date.today() if current_date > exp_date: return False, f"Subscription expired on {expiration_str}." return True, "Valid subscription." except Exception: return False, "Invalid key." # Prompt user for key print("šŸ”’ Welcome to F5-TTS Demo. Enter your license key (obtained after payment):") user_key = input("License Key: ").strip() valid, message = validate_key(user_key) is_valid_subscription = valid if valid: print("āœ… Subscription validated! You can now proceed with the demo.") else: print(f"āŒ {message}") print("\nšŸ’³ To renew or subscribe (5000 PKR per month plan):") print("1. Send payment via JazzCash to: 03099648389") print(" Account Holder: Mujahid Hussain") print("2. After payment, message the provider with your payment confirmation for a new license key.") print(" (Contact: [Add your contact here, e.g., email or X handle])") # Optionally, halt further execution here if desired # raise ValueError("Access denied due to invalid subscription.") #Mujahid