otp-agent
TypeScript icon, indicating that this package has built-in type declarations

3.0.3 • Public • Published

OTP-Agent NPM Version CI status Total Download

OTP(One-Time-Password) generator for JavaScript.

  • Generate OTP using numbers, alphabets and specialChars
  • Generate Custom OTP using specified characters

Installation

This is a Node.js module available through the npm registry.
Installation is done using the npm install command:

$ npm install otp-agent

Example & Usage (with import statement)

import { generateOTP, generateCustomOTP } from "otp-agent";

let otp = generateOTP();
console.log(otp); // 526775

otp = generateOTP({ length: 4, numbers: true, alphabets: true });
console.log(otp); // i5v3

// Custom OTP with specified characters (characters is mandatory field)
const customOTP = generateCustomOTP("Abc@123", { length: 5 });
console.log(customOTP); // 1@c3c

Example & Usage (with require statement)

const { generateOTP } = require("otp-agent");

// Default OTP length is 6 and max is 10
var otp = generateOTP();
console.log(otp); // 543921

otp = generateOTP({ length: 4, upperCaseAlphabets: true, specialChars: true });
console.log(otp); // RNRSXUQS

otp = generateOTP({
  length: 8,
  numbers: true,
  alphabets: true,
  upperCaseAlphabets: true,
  specialChars: true,
});
console.log(otp); // NZ9O#akS

Note

  • OTP can be generated with numbers, alphabets, uppercase alphabets, and special characters, and either of them can be chosen.
  • The OTP has a default length of 6 characters and a maximum length of 10.
  • If no choices are passed as a payload, then by default only number options are true.

Author

Rohan Shukla GitHub LinkedIn

License

© Licensed under the MIT License.

Package Sidebar

Install

npm i otp-agent

Weekly Downloads

733

Version

3.0.3

License

MIT

Unpacked Size

12.9 kB

Total Files

19

Last publish

Collaborators

  • rohanshukla