DEV Community

Mohana Vamsi
Mohana Vamsi

Posted on

Two-Factor Authentication System

This project implements a basic TOTP (Time-Based One-Time Password) generator using Python's pyotp library.

Code Example:

import pyotp

import time

key = pyotp.random_base32()

totp = pyotp.TOTP(key)

print("Generated OTP:", totp.now())

time.sleep(30)

print("Next OTP:", totp.now())

Use Case: Useful for understanding the workings of two-factor authentication and how time-based codes are generated.

Tip: Integrate this with a login system to simulate 2FA in action.

Top comments (0)