Home >Backend Development >Python Tutorial >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.
The above is the detailed content of Two-Factor Authentication System. For more information, please follow other related articles on the PHP Chinese website!