Giter VIP home page Giter VIP logo

otp-agent's Introduction

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.

otp-agent's People

Contributors

rohanshukla avatar

Forkers

coerick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.