An offline license key system for PySide6 applications.
This license key system provides the following features:
- Offline Validation: License keys are validated locally without requiring an internet connection (though an NTP check is prioritized if available).
- Hardware Binding: Keys are tied to specific machine hardware using a composite machine ID (CRC32 hash of MAC address, hostname, OS, CPU info), making them non-transferable between machines.
- Expiry Dates: Supports time-limited licenses with precise expiry dates (down to the second).
- License Types: Differentiates between "Standard" and "Lifetime" licenses.
- Anti-Tampering: Includes a mechanism to detect system clock tampering by storing the last known trusted time. If NTP is available, it's used as the primary time source; otherwise, it falls back to local system time with a stored timestamp check.
- User-Friendly Generator: A web-based (HTML/JavaScript) generator and a command-line Python script (
generator.py) to easily create new license keys. - Copy-to-Clipboard: The PySide6 application provides a "Copy Machine ID" button for easy key generation.
- Memorable Generator Inputs: The
generator.htmluseslocalStorageto remember previous input values. - Compact Key Format: License keys are short and easy to handle (e.g.,
RANDOMPART-EXPIRYDATETIME-CHECKSUM).
-
Clone the repository:
git clone <repository_url> cd pyside6-license-key
-
Install
uv(if you don't have it):uvis a fast Python package installer and resolver.powershell -c "irm https://astral.sh/uv/install.ps1 | more" # Or for Linux/macOS: # curl -LsSf https://astral.sh/uv/install.sh | sh
-
Install Dependencies:
uv sync
uv run main.pyThe application will launch, and if no valid license is found, it will prompt for one and display the machine ID.
You have two options for generating license keys:
Open generator.html directly in your web browser.
Important Security Note: This HTML generator exposes your SECRET_KEY in the browser's source code. It should only be used in a secure, private environment (e.g., locally on your machine) and never hosted publicly.
- Enter
SECRET_KEY: Ensure it matches the one in yoursrc/license_manager.pyfile. - Enter Machine ID: Copy the Machine ID displayed by your PySide6 application and paste it here.
- Select License Type: Choose "Standard" or "Lifetime".
- Set Duration: For "Standard" licenses, specify the years, months, days, and hours.
- Click "Generate Key": The key will appear, and you can copy it.
This script allows you to generate keys from your terminal.
-
Get Machine ID: Run
uv run generator.pywithout arguments to see the machine ID of your current system and usage examples. -
Generate Key: Use the following command structure:
# Example: Standard license for 1 year, 6 months uv run generator.py -id YOUR_MACHINE_ID -y 1 -m 6 # Example: Lifetime license uv run generator.py -id YOUR_MACHINE_ID -t lifetime # Example: Standard license for 10 days, 5 hours uv run generator.py -id YOUR_MACHINE_ID -d 10 -H 5
Replace
YOUR_MACHINE_IDwith the actual machine ID from the target system.
This project is licensed under the MIT License. See the License file for details.