Authentication & Identity

What Is TOTP (Time-Based One-Time Password)? Definition, Architecture & Defense

Quick Definition: TOTP (RFC 6238) is an offline two-factor authentication algorithm that computes a short-lived 6- to 8-digit code from a shared secret key and the current Unix timestamp, rotating every 30 seconds.

How TOTP (Time-Based One-Time Password) Works in Practice

When you scan a 2FA QR code into an authenticator app (such as Aegis, Ente Auth, 2FAS, or Bitwarden), your device stores a Base32-encoded secret seed. Every 30 seconds, both your phone and the server divide the current Unix time by 30 and compute an HMAC-SHA1 digest over that counter, truncating the result into a 6-digit numeric code without requiring internet connectivity.

Defensive Mitigation & Hardening Checklist

Use TOTP authenticator apps instead of SMS 2FA to eliminate SIM-swapping risk, and remember that TOTP codes can still be relayed by real-time Adversary-in-the-Middle (AitM) phishing sites—verify the domain URL or upgrade to passkeys where supported.

Hands-On Tool & Cheat Sheet


Related Security Glossary Terms