DEV Community

MC Naveen
MC Naveen

Posted on

10 2

How to Generate License Key with Node.js

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
Enter fullscreen mode Exit fullscreen mode

cd into the Directory

cd license-key
Enter fullscreen mode Exit fullscreen mode

Initiate Yarn

yarn init -y
Enter fullscreen mode Exit fullscreen mode

Install the required dependency

yarn add @mcnaveen/license-gen
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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

TPL5-IAQV-TUCR-8N7A-AQBW-EFSQ-HLK7-BND6
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

Then you'll get the output like this

BONP7PMW-2T4CTB58-9EOJT7CU-Q72TVKGL
Enter fullscreen mode Exit fullscreen mode

This module as supports ES6 imports

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

Please comment your thoughts


Links:

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay