This project provides a complete Node.js implementation of Time-Based One-Time Password (TOTP) compatible with Google Authenticator. It generates a Base32-encoded secret, produces an OTP Auth URL, displays a QR code in the terminal, and verifies OTP codes entered by users with configurable retry limits.
- 🔑 Generate secure Base32-encoded TOTP secret key
- 🔗 Create OTP Auth URL for Google Authenticator
- 📟 Display QR code directly in terminal (no browser needed)
- ✅ Validate TOTP codes entered by user with up to 3 retry attempts
- ⚡ No external TOTP libraries (pure Node.js + standard packages)
git clone https://github.com/NeaByteLab/TOTP-Generator.git
cd TOTP-Generatornpm installnode index.js- 🔑 The app generates a TOTP secret key.
- 🔗 It creates an OTP Auth URL and displays the QR code in the terminal.
- 📲 You scan the QR code using Google Authenticator or compatible app.
- ⌨️ The app prompts you to enter the 6-digit code.
- 📝 The app verifies the entered code and informs whether it is valid or invalid.
- ♻️ You have up to 3 attempts by default.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█ ▄▄▄▄▄ █▄▀ ▀ ▄▄███▄█▄ █▀██ █ █ ▄▄▄▄▄ █
█ █ █ █ █▀▄ █▄ ██▄██ ▀███ █ █ █
█ █▄▄▄█ █▄█▀ ▄ ▄▄▄ ▀▀▀▄▄▄ ▄▄█ █▄▄▄█ █
█▄▄▄▄▄▄▄█▄█ █ █▄█ ▀ ▀▄█▄█ █ █▄█▄▄▄▄▄▄▄█
█▄▄ ▄█▀▄▀▄█ ▄ ▀ █ ▀ ▄ ▀▀███▄█ █▀▄▄▄▀▄█
██▄ ▀█ ▄▀ ██▄▄▀ █▄███▀▄▄ ▀▀█▀▄█ ▄▀▀▀██
█ █▀█▄▄▄ ▄▄█▀ █ █▀█▄█▀██ ▀▀ ▄ ▀▀▄ ▄ █
███ ▀█▄▄█▀ ▄ █▄▀██▄▀▄█ ▄█▄█▄▀▀█▀█▀▀▄ ▀█
█▄██ ▄ ▄██▄ █▄ ▀▀▄▄ ▀▀▀▄▀▄ █▀█ ▀▄█▄▄▄▀█
██ █ ▀█▄██ ▀▀██▀ ▄▀▀▀▄▄█▀ ▄█▄█▀▀ █▄▄ ▄█
██▀█ ▄▄▄███ ███ █▀▄█ ▄▀█▀▄▀▄██ █ ██▀▀██
█▀ ▀▄▄▀▄█▀▀▀▄█ █▀██▄█▄ ▀██▀█▄▀▄ ███
████ ▀█▄█▀██ █▀▀▀▀▀███▄▄█ ▄▄ █ ▄ █
█▀▄▄▄▄█▄▀▄ ▀█ ▀▄█ █▄ ▄ █▀▀▄ ▀▀▀█▄█▄█ ██
█████▄▄▄█ █▄▀▀█▀▀▄▄▀▀█▄ ▄ █ ▄▄▄ █ █
█ ▄▄▄▄▄ ██▄▄▄ ██ ▄▀█▄▀██▄▄█ █▄█ █ ▄█
█ █ █ █▀▄▄▄ ▀ █▄ ▄ ▀██ ▀ █▀ █
█ █▄▄▄█ █ ▀▀▄▄▄█▀█▄▄▀ █ ▄ ▀█ ▄ ▄ ███
█▄▄▄▄▄▄▄█▄▄▄█▄█▄▄▄███▄███▄▄▄██▄▄▄██▄▄▄█
Enter OTP: 123456
-> OTP Invalid
Enter OTP: 654321
-> OTP Invalid
Enter OTP: 789012
-> OTP Valid
crypto— For secure random key generationqrcode— For generating QR code dataqrcode-terminal— To render QR code in terminalreadline-sync— For synchronous terminal input
MIT License © 2025 NeaByteLab