First Commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
"""TOTP code generation using pyotp."""
|
||||
|
||||
import pyotp
|
||||
|
||||
|
||||
def generate_totp(secret: str) -> str:
|
||||
"""Generate the current TOTP code from a base32 secret."""
|
||||
totp = pyotp.TOTP(secret)
|
||||
return totp.now()
|
||||
|
||||
|
||||
def verify_totp(secret: str, code: str) -> bool:
|
||||
"""Verify a TOTP code against a secret (useful for debugging setup)."""
|
||||
totp = pyotp.TOTP(secret)
|
||||
return totp.verify(code)
|
||||
Reference in New Issue
Block a user