otp-agent
v3.0.3
Published
OTP(One-Time-Password) generator for JavaScript
Downloads
2,054
Maintainers
Readme
OTP-Agent
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
License
© Licensed under the MIT License.