How to Generate License Key with Node.js

·

1 min read

This post will help you to generate License keys with Node.js

I'll walk you through step by step process

Create a directory

mkdir license-key

cd into the Directory

cd license-key

Initiate Yarn

yarn init -y

Install the required dependency

yarn add @mcnaveen/license-gen

Create a new file called index.js and paste the below code.

const licenseGen = require("@mcnaveen/license-gen")

const key = licenseGen(32)
console.log(key)

Now Save the File Then Run node index.js You'll get the license key in the console like below

TPL5-IAQV-TUCR-8N7A-AQBW-EFSQ-HLK7-BND6

You can alter the license key as per your need.

If you want more characters, change the value from 32 to something else.

Or if you need pair of 8 values with the same 32 characters modify the code like this.

const licenseGen = require("@mcnaveen/license-gen")

const key = licenseGen(32, 8)
console.log(key)

Then you'll get the output like this

BONP7PMW-2T4CTB58-9EOJT7CU-Q72TVKGL

This module supports ES6 imports

If you like this post leave a heart or Bookmark it for later.

Please comment with your thoughts


Links: