DEV Community

Rahul Varma
Rahul Varma

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)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →