npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2026 โ€“ย Pkg Stats / Ryan Hefner

license-keys

v1.0.8

Published

๐Ÿ”‘ License-Keys: Generate secure, efficient license keys for your applications.

Readme

License Keys NPM-Package

npm npm GitHub release (latest by date) GitHub issues GitHub pull requests GitHub stars

License Keys NPM-Package is a Node.js package that allows you to generate, encrypt, and verify license keys using MySQL and OpenPGP.js.

Table of Contents

Installation

npm install license-keys

Usage

const { createKey, verifyKey, generateKeyPair } = require("license-keys");

// Generate a PGP key pair
(async () => {
    const keyPair = await generateKeyPair("John Doe", "[email protected]", "secure-passphrase");
    console.log(keyPair);
})();

// Generate a license key and store it in a MySQL database
(async () => {
    const options = {
        length: 4,
        charset: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
        MySQL: {
            host: "localhost",
            user: "root",
            password: "password",
            database: "license_keys",
            tableName: "user_keys",
            columnName: "license_key"
        },
        OpenPGP: {
            publicKey: "-----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----"
        }
    };

    const key = await createKey(options);
    console.log(key);
})();

// Verify a license key
(async () => {
    const options = {
        key: "ABC1-DEF2-GHI3-JKL4",
        MySQL: {
            host: "localhost",
            user: "root",
            password: "password",
            database: "license_keys",
            tableName: "user_keys",
            columnName: "license_key"
        },
        OpenPGP: {
            privateKey: "-----BEGIN PGP PRIVATE KEY BLOCK----- ... -----END PGP PRIVATE KEY BLOCK-----",
            passphrase: "secure-passphrase"
        }
    };

    const result = await verifyKey(options);
    console.log(result);
})();

API

createKey

Generates a license key based on the provided options, encrypts it with a public key (if provided), and stores it in the MySQL database.

createKey(options)

Parameters

  • options: (Object)
    • length: (number) The length of each segment in the generated key.
    • charset: (string, optional) The character set to use when generating the key.
    • MySQL: (Object) MySQL-related options.
      • host: (string) MySQL server host.
      • user: (string) MySQL user.
      • password: (string) MySQL password.
      • database: (string) MySQL database.
      • tableName: (string) MySQL table name.
      • columnName: (string) MySQL table column name.
    • OpenPGP: (Object)
      • publicKey: (string) PGP public key.

Returns

  • A promise that resolves to an object containing:
    • plainText: (string) The generated plain text key.
    • encrypted: (string) The encrypted key (if a public key is provided).

verifyKey

Receives a license key and checks if it exists within the MySQL database, then verifies it and removes it.

verifyKey(options)

Parameters

  • options: (Object)
    • key: (string) The license key to verify.
    • MySQL: (Object) MySQL-related options.
      • host: (string) MySQL server host.
      • user: (string) MySQL user.
      • password: (string) MySQL password.
      • database: (string) MySQL database.
      • tableName: (string) MySQL table name containing the license keys.
      • columnName: (string) MySQL table column name containing the license keys.
    • OpenPGP: (Object) OpenPGP-related options.
      • privateKey: (string) The private key used for decrypting the license key.
      • passphrase: (string) The passphrase used for decrypting the license key.

Returns

  • Promise<boolean>: A promise that resolves to a boolean indicating if the license key was verified and removed from the MySQL database.

generateKeyPair

Generates a PGP key pair.

generateKeyPair(name, email, passphrase)

Parameters

  • name: (string) The user name associated with the key. the key pair.
  • email: (string) The email address associated with the key pair.
  • passphrase: (string) The passphrase to use for protecting the private key.

Returns

  • Promise<{publicKey: string, privateKey: string}>: A promise that resolves to an object containing the generated public and private keys as strings.

Contributing

Contributions are welcome! If you have any suggestions, improvements, or issues, feel free to open a pull request or create an issue on the GitHub repository.