@hester60/generate-otp
v1.0.2
Published
Generate one-time passwords based on configuration.
Downloads
3
Readme
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