Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kavingovind/generate-one-time-password

A lightweight npm package for generating secure 6-digit one-time passwords (OTP) for authentication and verification purposes.
https://github.com/kavingovind/generate-one-time-password

generate-otp one-time-password otp-generator otp-number

Last synced: 12 days ago
JSON representation

A lightweight npm package for generating secure 6-digit one-time passwords (OTP) for authentication and verification purposes.

Awesome Lists containing this project

README

        

# Generate One Time Password(OTP)

A lightweight npm package for generating one-time passwords (OTP) with adjustable lengths between 4 and 12 digits, ideal for authentication and verification.

## Installation

```bash
$ npm install generate-one-time-password --save

or

$ yarn add generate-one-time-password
```

## Usage

```javascript
import { generateOTP } from "generate-one-time-password";

const otp = generateOTP();
console.log(otp); // 490605

const otpcode = generateOTP(4);
console.log(otpcode); // 3075

const otpcode = generateOTP(8);
console.log(otpcode); // 24837554
```

## API Reference

Generate a random OTP number with a length between 4 and 12 digits.

| Function Arguments | Default Value | Type | Description |
| :----------------- | :------------ | :----------- | ------------------------------------------------------------------------------------------------------------ |
| `4` - `12` | `6` | **Optional** | The number of digits in a one-time password (OTP). If no option is specified, the OTP will be 6 digits long. |

## License

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/)

## Authors

- [@kavingovind](https://www.github.com/kavingovind)