UNPKG

otp-generator-module

Version:

A simple and flexible OTP (One-Time Password) generator module for JavaScript and TypeScript. Supports numeric, alphabetic, and special character combinations with customizable options.

50 lines (32 loc) 1.54 kB
# 🔐 OTP Generator Module A simple and flexible OTP (One-Time Password) generator module for JavaScript and TypeScript. Supports numeric, alphabetic, and special character combinations with customizable options. ## 📦 Installation ```bash npm install otp-generator-module ``` ## Usage 🛠️ ```javascript import { generateOTP } from 'otp-generator-module'; // 1️⃣ Default 4-digit numeric OTP console.log(generateOTP()); // e.g., '3847' // 2️⃣ 6-digit numeric OTP console.log(generateOTP({ length: 6 })); // 3️⃣ 6-digit with lowercase alphabets console.log(generateOTP({ length: 6, alphabets: true })); // 4️⃣ 6-digit with uppercase letters console.log(generateOTP({ length: 6, upperCase: true })); // 5️⃣ 6-digit with special characters console.log(generateOTP({ length: 6, specialChars: true })); // 6️⃣ 6-digit with alphabets + uppercase console.log(generateOTP({ length: 6, alphabets: true, upperCase: true })); // 7️⃣ 6-digit with alphabets + special characters console.log(generateOTP({ length: 6, alphabets: true, specialChars: true })); // 8️⃣ 6-digit with uppercase + special characters console.log(generateOTP({ length: 6, upperCase: true, specialChars: true })); // 9️⃣ 6-digit with alphabets + uppercase + special characters console.log(generateOTP({ length: 6, alphabets: true, upperCase: true, specialChars: true })); ``` ## License 📜 MIT License. ## Downloads ![npm](https://img.shields.io/npm/dt/otp-generator-module)