Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/kavingovind/generate-one-time-password
- Owner: kavingovind
- License: mit
- Created: 2024-04-15T19:12:41.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-13T07:36:22.000Z (5 months ago)
- Last Synced: 2025-01-17T20:06:00.076Z (17 days ago)
- Topics: generate-otp, one-time-password, otp-generator, otp-number
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/generate-one-time-password
- Size: 41 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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 --saveor
$ yarn add generate-one-time-password
```## Usage
```javascript
import { generateOTP } from "generate-one-time-password";const otp = generateOTP();
console.log(otp); // 490605const otpcode = generateOTP(4);
console.log(otpcode); // 3075const 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)