1.0.2 • Published 2 years ago

@hester60/generate-otp v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago