@hester60/generate-otp
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Generate OTP

Overview

Generate one-time passwords based on configuration.

Install

$ npm i generate-otp

Usage

To generate OTP, you need to call generateOtp() by passing your configuration (optional):

const otp: string = generateOtp();

Default configuration, you can overwrite it with your own values:

import { OtpConfig } from './OtpConfig';

const config: OtpConfig = {
    length: 6,
    digitsOnly: true,
    allowUppercase: true,
}

Custom configuration example:

import generateOtp from './generateOtp';

const otp: string = generateOtp({
    length: 10,
    digitsOnly: false
})

console.log('Otp: ', otp);

This configuration will generate an Otp with a length of 10 and alphanumeric characters with lower and uppercase:

// console.log() result
Otp: auYYD6opd9

Readme

Keywords

Package Sidebar

Install

npm i @hester60/generate-otp

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

11.9 kB

Total Files

29

Last publish

Collaborators

  • hester60