pro-otp-generator
v1.1.1
Published
A secure and flexible OTP generator supporting numeric, hex, and alphanumeric with expiry sessions
Downloads
8
Maintainers
Readme
Pro-OTP-Generator 🔐
A robust and flexible Node.js module for generating and verifying One-Time Passwords (OTPs). This project provides a secure way to create OTPs with customizable options, including length, type (numeric, hex, alphanumeric), and expiration time. It's designed to be easily integrated into various applications requiring secure user authentication.
🚀 Features
- OTP Generation: Generates OTPs with configurable length, type (numeric, hex, alphanumeric), and expiration time.
- Secure Randomness: Uses the
cryptomodule for cryptographically secure random number generation. - OTP Verification: Verifies user-provided OTPs against stored sessions, ensuring validity and preventing reuse.
- Expiration Handling: Automatically expires OTPs after a specified time, enhancing security.
- Human-Friendly Option: Generates human-readable alphanumeric OTPs by excluding easily confused characters.
- Customizable OTP Types: Supports numeric, hexadecimal, and alphanumeric OTP generation to suit different application needs.
🛠️ Tech Stack
- Backend: Node.js
- Cryptography:
crypto(Node.js built-in module) - Package Manager: npm
📦 Getting Started
Follow these steps to set up and run the Pro-OTP-Generator in your local environment.
Prerequisites
- Node.js (v14 or higher)
- npm (Node Package Manager)
Installation
Usages:
npm install pro-otp-GenratorInstall the dependencies (though there are no declared dependencies, this step is good practice):
npm install
Running Locally
Since this library is designed to be integrated into another project, you won't "run" it directly. Instead, you'll import it into your project and use its functions. Here's a basic example of how you might use it:
Create a new Node.js project or use an existing one.
Copy the
index.jsfile into your project.Use the
generateOTPandverifyOTPfunctions in your code:const { generateOTP, verifyOTP } = require('./index'); // Adjust path as needed // Generate an OTP const otpSession = generateOTP({ length: 6, expiresIn: 60 }); // 6-digit OTP, expires in 60 seconds console.log("Generated OTP:", otpSession.otp); // Simulate user entering the OTP const userOTP = otpSession.otp; // Verify the OTP const verificationResult = verifyOTP(userOTP, otpSession); if (verificationResult) { console.log("OTP Verified Successfully!"); } else { console.log("OTP Verification Failed."); }
📂 Project Structure
Pro-OTP-Genrator/
├── index.js # Main module for OTP generation and verification
├── package.json # Project metadata and dependencies
├── cryptoModule.env # Example of using crypto module (not core functionality)
└── README.md # Project documentation (this file)🤝 Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with descriptive messages.
- Push your changes to your fork.
- Submit a pull request.
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
📬 Contact
Deep Buddhadev - [[email protected]]
💖 Thanks
Thank you for using Pro-OTP-Generator! We hope this module helps you build secure and reliable authentication systems.
