Skip to content

tsrinarmwong/license-key-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” LICENSE KEY GENERATOR (PKI-Based Signing)

A lightweight open-source JavaScript library for signing and verifying software license key using RSA 2048-bit encryption.

βš›οΈ I'm actively pushing this to be Post-Quantum Computing (PQC) compatible to future-proof security.

✨ Features

  • πŸ”‘ Generate RSA Key Pairs
  • πŸ” Sign License Keys
  • βœ… Verify Signed Licenses
  • πŸ”’ Uses SHA256 + RSA for Security
  • πŸ›  Minimal & Easy to Integrate
  • 🌍 Live API Hosted on Render

πŸ“‘ Table of Contents

πŸš€ How It Works

This API allows you to generate RSA key pairs, sign software license keys, and verify them using cryptographic signing.

1️⃣ Generate an RSA Key Pair – Get a public and private key. The private key is yours to keep.
2️⃣ Sign a License Key – Use your private key to sign a license.
3️⃣ Verify a License – Use the public key to validate the signature.

⚠️ Warning: The API DOES NOT store any keys for you. If you do not save your private key when generated, it will be lost forever! Users manage their own key storage.

πŸ”‘ Where Do the Keys Live?

  • Generated Keys: When you generate a key pair, the public and private keys exist only in memory until you save them.
  • Private Key: This key is meant to be kept secret. If you lose it, you cannot re-create or retrieve it.
  • Public Key: You can store and distribute this safely. It is used to verify signed licenses.

πŸ”Ή Note: This API DOES NOT store your keys or license data.
πŸ‘€ If you need a hosted key storage & validation service, stay tuned for our upcoming managed API service!


🌍 Live API (No Setup Required!)

The API is deployed on Render and can be accessed directly!

Feature Details
Base URL https://license-signing-api.onrender.com
Swagger API Docs https://license-signing-api.onrender.com/api-docs/

API Endpoints

GET /generate-keys

  • Returns: { publicKey: string, privateKey: string }
  • Description: Generates a new RSA 2048-bit key pair.
  • Example Response:
    {
      "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhki...\n-----END PUBLIC KEY-----",
      "privateKey": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBA...\n-----END PRIVATE KEY-----"
    }

POST /sign-license

  • Request Body:
    {
      "licenseKey": "USER123-PRODUCT456-EXP20251231",
      "privateKey": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBA...\n-----END PRIVATE KEY-----"
    }
  • Returns: { signature: string }
  • Description: Signs a license key using the provided private key.
  • Example Response:
    {
      "signature": "k7d9f8a8g9s7d9f8a7g9s7d..."
    }

POST /verify-license

  • Request Body:
    {
      "licenseKey": "USER123-PRODUCT456-EXP20251231",
      "signature": "k7d9f8a8g9s7d9f8a7g9s7d...",
      "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhki...\n-----END PUBLIC KEY-----"
    }
  • Returns: { valid: boolean }
  • Description: Verifies if the given license key and signature match the public key.
  • Example Response:
    {
      "valid": true
    }

πŸ”Ή Try it in Swagger UI

πŸ“Œ Swagger API Docs: https://license-signing-api.onrender.com/api-docs/


⚑ Usage (Local Development)

πŸ“¦ Installation

To install this package locally, run:

npm install

Requirements

  • Node.js 16+
  • Express.js (for API)
  • Crypto module (built into Node.js)

1️⃣ Generate a Key Pair

To create an RSA public-private key pair, use:

const { generateKeyPair } = require("./src/generateKeys");

const { privateKey, publicKey } = generateKeyPair();
console.log("Private Key:", privateKey);
console.log("Public Key:", publicKey);

2️⃣ Sign a License Key

To sign a license key with your private key, use:

const { signLicense } = require("./src/signLicense");

const licenseKey = "USER123-PRODUCT456-EXP20251231";
const signature = signLicense(licenseKey, privateKey);
console.log("πŸ” Signature:", signature);

3️⃣ Verify a License Key

To verify a license key, use:

const { verifyLicense } = require("./src/verifyLicense");

const isValid = verifyLicense(licenseKey, signature, publicKey);
console.log("βœ… Valid License:", isValid);

πŸ§ͺ Running Tests

To run the unit tests:

npm test

or

jest

πŸ“œ License

This project is licensed under the MIT License.
Feel free to modify and use it in your own projects.


🀝 Contributions

Pull requests are welcome! Please follow the contribution guidelines in docs/CONTRIBUTING.md.

I'm pushing this tool to GitHub Marketplace to make it easier for developers and teams to integrate secure license key management into their workflow.

πŸ’‘ Want to support development?
This project is open for sponsorship! Your contributions help me bring Post-Quantum Security to software licensing.

πŸ‘‰ Sponsor me on GitHub πŸš€


πŸ“§ Contact


πŸ”₯ Happy coding! πŸš€

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors