Skip to content

tech-adarshjha/license-key-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Desktop App License Key Generator

A simple, secure command-line tool for generating RSA-signed license keys for desktop applications. This tool helps you create machine-specific licenses with customizable expiration dates.

What Does It Do?

This tool generates cryptographically signed license keys that:

  • Are tied to a specific machine's MAC address
  • Have a customizable validity period (in days)
  • Use RSA signature verification to prevent tampering
  • Can be validated offline by your desktop application

Features

  • Secure: Uses RSA-2048 encryption with SHA-256 signatures
  • Machine-Specific: License keys are bound to MAC addresses
  • Offline Validation: No internet connection required for verification
  • Easy to Use: Simple command-line interface
  • Organized: Automatically saves keys with timestamps

How It Works

  1. Key Generation (this tool):

    • Takes MAC address and validity period as input
    • Signs the data with a private key
    • Generates a Base64-encoded license key
    • Saves it to a timestamped file
  2. Key Validation (your app):

    • Uses the included JavaScript validation code
    • Verifies the signature with the public key
    • Checks MAC address match
    • Tracks license expiration

Getting Started

Prerequisites

  • Rust (1.70 or later)
  • Cargo (comes with Rust)

Building from Source

# Clone the repository
git clone <your-repo-url>
cd license-key-generator

# Build the project
cargo build --release

# The executable will be in target/release/

Running the Generator

# On macOS/Linux
./target/release/desktop-app-license-key-generator

# On Windows
target\release\desktop-app-license-key-generator.exe

Usage

  1. Run the application

  2. Enter the MAC address of the target machine

    • Example: 00:1B:44:11:3A:B7
  3. Enter the number of days the license should be valid

    • Example: 365 for one year
  4. Enter a machine name (optional)

    • This is used for the filename
    • Press Enter to use the MAC address as the name
  5. Get your license key

    • The key is displayed in the terminal
    • Automatically saved to License Keys/<name>_<timestamp>.txt

Example

Desktop App License Key Generator

Enter MAC ID:
00:1B:44:11:3A:B7

Enter number of days:
365

Enter machine name (optional, press Enter to use MAC ID):
John-Laptop

License key saved to file: License Keys/John-Laptop_20251205143022.txt
License Key: <base64-encoded-license-key>

Press Enter to exit...

Integrating with Your App

The js/main.js file contains a complete Node.js implementation for validating licenses in your application. Key functions:

  • saveLicense(licenseKey) - Save and validate a new license
  • validateLicense() - Check if the current license is valid
  • getMacAddress() - Get the machine's MAC address

Quick Integration

const { validateLicense, saveLicense } = require('./main');

// When user enters a license key
try {
  saveLicense(userEnteredKey);
  console.log('License activated successfully!');
} catch (error) {
  console.log('Invalid license key');
}

// Check license on app startup
if (validateLicense()) {
  // License is valid, start app
} else {
  // License invalid or expired, show activation screen
}

Security Notes

⚠️ Important: The private key in this repository is for demonstration purposes. For production use:

  1. Generate your own RSA key pair:

    # Generate private key
    openssl genrsa -out private_key.pem 2048
    
    # Extract public key
    openssl rsa -in private_key.pem -pubout -out public_key.pem
  2. Update the keys:

    • Replace the private_key_pem in src/main.rs
    • Replace the PUBLIC_KEY in js/main.js
  3. Keep your private key secure:

    • Never share it publicly
    • Store it in a secure location
    • Consider using environment variables or secure vaults

File Structure

license-key-generator/
├── src/
│   └── main.rs          # Key generator (Rust)
├── js/
│   └── main.js          # License validator (Node.js)
├── assets/
│   └── icon.ico         # Application icon
├── License Keys/        # Generated keys saved here
├── Cargo.toml          # Rust dependencies
└── README.md           # You are here

License Format

License keys are Base64-encoded and contain:

  • RSA signature of the MAC+days payload
  • Validity period (in days)

Format: <signature>__<days>__

Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest features
  • Submit pull requests

License

This project is available as-is for personal and commercial use. Feel free to modify and adapt it to your needs.

Questions?

If you have questions or run into issues, please open an issue on GitHub.


Made with ❤️ for developers who need simple, secure licensing for their desktop apps.

About

A simple, secure command-line tool for generating RSA-signed license keys for desktop applications. This tool helps you create machine-specific licenses with customizable expiration dates.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors