Welcome to the 2FA Codes Generator repository! This project provides a simple and efficient way to generate and verify HOTP and TOTP codes using Python and Flask.
- 🔑 Generate random secrets for 2FA
- 🔢 Generate HOTP (HMAC-based One-Time Password) codes
- ⏰ Generate TOTP (Time-based One-Time Password) codes
- ✅ Verify HOTP and TOTP codes
- 🔗 Generate OTPAuth URLs for easy integration with authenticator apps
-
⭐ First give me a star
-
Clone the repository:
git clone https://github.com/xe-4f14-5d3-6s2/2fa-codes-generator.git
cd 2fa-codes-generator
- Create a virtual environment and activate it:
python3 -m venv venv
source venv/bin/activate
- Install the required dependencies:
pip install -r requirements.txt
- Run the Flask application:
flask run
- Use the following endpoints to generate and verify codes:
-
Generate Secret
GET /generate/secret?length=<length>
length
: Length of the secret (default: 32)
-
Generate TOTP
GET /generate/totp?secret=<secret>&digits=<digits>&period=<period>
secret
: The secret keydigits
: Number of digits in the OTP (default: 6)period
: Time period in seconds (default: 30)
-
Generate HOTP
GET /generate/hotp?secret=<secret>&counter=<counter>&digits=<digits>
secret
: The secret keycounter
: Counter valuedigits
: Number of digits in the OTP (default: 6)
-
Generate OTPAuth URL
GET /generate/url?secret=<secret>&label=<label>&issuer=<issuer>&algorithm=<algorithm>&digits=<digits>&period=<period>&type=<type>
secret
: The secret keylabel
: Label for the OTPissuer
: Issuer name (optional)algorithm
: Hash algorithm (default: SHA1)digits
: Number of digits in the OTP (default: 6)period
: Time period in seconds (default: 30)type
: Type of OTP (totp or hotp, default: totp)
-
Verify TOTP
GET /verify/totp?secret=<secret>&token=<token>&digits=<digits>&period=<period>&window=<window>
secret
: The secret keytoken
: The OTP token to verifydigits
: Number of digits in the OTP (default: 6)period
: Time period in seconds (default: 30)window
: Verification window (default: 1)
-
Verify HOTP
GET /verify/hotp?secret=<secret>&token=<token>&counter=<counter>&digits=<digits>&window=<window>
secret
: The secret keytoken
: The OTP token to verifycounter
: Counter valuedigits
: Number of digits in the OTP (default: 6)window
: Verification window (default: 1)
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
Thank you for using 2FA Codes Generator! If you have any questions or feedback, feel free to reach out. 2FA Codes Generator