Skip to content

ykywz-python/pyside6-license-key

Repository files navigation

PySide6 License Key

An offline license key system for PySide6 applications.

Features

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.html uses localStorage to remember previous input values.
  • Compact Key Format: License keys are short and easy to handle (e.g., RANDOMPART-EXPIRYDATETIME-CHECKSUM).

Setup

  1. Clone the repository:

    git clone <repository_url>
    cd pyside6-license-key
  2. Install uv (if you don't have it): uv is 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
  3. Install Dependencies:

    uv sync

Usage

Running the PySide6 Application

uv run main.py

The application will launch, and if no valid license is found, it will prompt for one and display the machine ID.

Generating License Keys

You have two options for generating license keys:

1. Using the Web-based Generator (generator.html)

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.

  1. Enter SECRET_KEY: Ensure it matches the one in your src/license_manager.py file.
  2. Enter Machine ID: Copy the Machine ID displayed by your PySide6 application and paste it here.
  3. Select License Type: Choose "Standard" or "Lifetime".
  4. Set Duration: For "Standard" licenses, specify the years, months, days, and hours.
  5. Click "Generate Key": The key will appear, and you can copy it.

2. Using the Command-Line Python Generator (generator.py)

This script allows you to generate keys from your terminal.

  1. Get Machine ID: Run uv run generator.py without arguments to see the machine ID of your current system and usage examples.

  2. 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_ID with the actual machine ID from the target system.

License

This project is licensed under the MIT License. See the License file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published