๐ Introduction
In the rapidly evolving digital world, securing user data is crucial. otp-agent
is a powerful JavaScript package designed to generate one-time passwords (OTPs) to strengthen your application's security. It supports various types of OTPs, including Time-based One-Time Passwords (TOTP), HMAC-based One-Time Passwords (HOTP), and custom OTPs.
Why OTP-Agent?
otp-agent
streamlines OTP generation and management, making it essential for any secure application. Key benefits include:
- ๐ก๏ธ Enhanced Security: Adds an extra layer of protection.
-
๐ Versatility:
- Multiple OTP Types: Supports various OTPs (TOTP, HOTP) and custom OTPs.
- Customizability: Create custom OTPs with specific characters and lengths.
- Flexible Integration: Easily integrate into websites, mobile apps, or desktop applications.
- Wide Use Cases: Suitable for user authentication, transaction verification, and access control.
- Compatibility: Works seamlessly with CommonJS and ES6 modules.
- โก Easy Integration: Quick to install and implement.
๐ ๏ธ Installation
Ensure you have Node.js installed, then run:
With npm:
npm install otp-agent
With Yarn:
yarn add otp-agent
๐ Key Features
๐ OTP (One-Time Password)
Generate customizable OTPs up to 100 characters long.
import { generateOTP } from 'otp-agent';
let otp = generateOTP();
console.log(otp); // 526775
otp = generateOTP({ length: 4, numbers: true, alphabets: true });
console.log(otp); // i5v3
otp = generateOTP({
length: 8,
numbers: true,
alphabets: true,
upperCaseAlphabets: true,
specialChars: true,
});
console.log(otp); // NZ9O#akS
Example Usage (with require
statement)
const { generateOTP } = require('otp-agent');
const otp = generateOTP();
console.log(otp); // 543921
โจ Custom OTP
Create OTPs with specified characters and lengths.
import { generateCustomOTP } from 'otp-agent';
const customOTP = generateCustomOTP('Abc@123', { length: 5 });
console.log(customOTP); // 1@c3c
โณ TOTP (Time-based One-Time Password)
Generate time-based OTPs that change periodically.
import { generateTOTP } from 'otp-agent';
const totp = generateTOTP({ secret: 'YOURSECRET' });
console.log(totp); // 123456
๐ HOTP (HMAC-based One-Time Password)
Create counter-based OTPs for persistent use until authenticated.
import { generateHOTP } from 'otp-agent';
const hotp = generateHOTP({ secret: 'YOURSECRET', counter: 1 });
console.log(hotp); // 654321
โ Conclusion
Enhance your application's security with otp-agent
. It's flexible, easy to integrate, and significantly boosts user data protection.
Start using otp-agent
today and secure your applications effortlessly!
Happy coding! ๐
Top comments (0)