nodejs-otp-generator
v1.0.2
Published
A lightweight node.js package for generating cryptographically secure OTP codes — ideal for SMS, email, and other verification flows.
Readme
nodejs-otp-generator
A lightweight node.js package for generating cryptographically secure OTP codes — ideal for SMS, email, and other verification flows.
📦 Installation
Use npm, yarn or pnpm:
npm install nodejs-otp-generator
# or
yarn add nodejs-otp-generator
# or
pnpm add nodejs-otp-generator🔧 Utilization
import { generateOTP } from "nodejs-otp-generator";
const otp = generateOTP(10, {
digits: true,
lowerCaseAlphabets: true,
upperCaseAlphabets: true,
specialChars: false,
});
console.log("OTP -> ", otp); // OTP -> eyRjCOTj4v🔢 Arguments
length- number - max length must be between 4 and 10.options- object - all generation code available options.
🧩 Options
| Property | Type | Default | Required | Description |
|-----------|-------|----------|------------|-------------|
| numeric | boolean | false | ❌ No | accepts numeric digits. |
| lowerAlphabet | boolean | false | ❌ No | accepts lowercase alphabet. |
| upperAlphabet | boolean | false | ❌ No | accepts uppercase alphabet. |
| specialChar | boolean | false | ❌ No | accepts special chars. |
