TOTP: How Authenticator Codes Work
Security & Identity

TOTP: How Authenticator Codes Work

Subtitle: A shared secret plus a shared clock, no network needed

Panel 2 - THE ALGORITHM (RFC 6238):

K = shared secret, Base32 encoded T = floor(unix time / 30) HMAC-SHA1(K, T) gives 20 bytes Dynamic truncation to 31-bit int int mod 10^6 gives 6 digits

Panel 3 - WHY IT WORKS OFFLINE:

Nothing is sent to generate a code Both sides share time, not messages The secret never leaves the device Each code lives about 30 seconds Server allows only a small drift window

Panel 4 - COMMON MISTAKES:

Accepting the same code twice Drift window too wide, plus or minus 10 No rate limit, so 10^6 is guessable Storing K in plaintext at rest No backup codes, users get locked out

Callout box: Simple idea: a password proves what you know, TOTP proves you still hold the secret right now.