Skip to content
Vol. 1 · Ed. 2026
CyberGlossary
Entry № 1280

Time-Based One-Time Password (TOTP)

Reviewed byCybersecurity entrepreneur & security researcher

What is Time-Based One-Time Password (TOTP)?

Time-Based One-Time Password (TOTP)A one-time password algorithm defined in RFC 6238 that derives a short code from a shared secret and the current time, rotating every 30 seconds.


TOTP, specified in RFC 6238, is a time-based profile of the HOTP algorithm (RFC 4226). Both sides compute HOTP(K, T) where the moving factor T is floor((currentUnixTime − T0) / X); by default T0 is 0 and the time step X is 30 seconds. The HMAC output — HMAC-SHA1 by default, with SHA-256 or SHA-512 permitted — is reduced to a 6–8 digit code by RFC 4226 dynamic truncation. The shared secret is normally provisioned through an otpauth:// URI, the de facto Key URI Format popularised by Google Authenticator, encoded as a QR code with a Base32 seed; servers typically accept the adjacent window (±1 step) to tolerate clock skew.

Because the code is short and reusable for the whole 30-second window, TOTP is defeated by real-time adversary-in-the-middle phishing kits such as Evilginx, EvilProxy and Tycoon 2FA, which relay the victim's code to the genuine site before it expires. Server-side seed stores are a single point of failure, and device malware can read provisioned seeds. Defences include rate-limiting code attempts, binding sessions, alerting on new devices, and preferring phishing-resistant FIDO2/WebAuthn passkeys for high-value accounts.

flowchart LR
  S["Shared Base32 secret"] --> C["Authenticator app: HMAC-SHA1 then truncate"]
  S --> V["Server: HMAC-SHA1 then truncate"]
  T["Current Unix time div 30"] --> C
  T --> V
  C -->|"6-digit code"| V
  V --> R{"Codes match within plus or minus 1 step?"}
  R -->|Yes| OK["Access granted"]
  R -->|No| NO["Rejected"]

● Examples

  1. 01

    Scanning a QR code into Google Authenticator to enable 2FA on a GitHub account.

  2. 02

    Entering a 6-digit code from an authenticator app when logging in to a banking portal.

● Frequently asked questions

What is Time-Based One-Time Password (TOTP)?

A one-time password algorithm defined in RFC 6238 that derives a short code from a shared secret and the current time, rotating every 30 seconds. It belongs to the Identity & Access category of cybersecurity.

What does Time-Based One-Time Password (TOTP) mean?

A one-time password algorithm defined in RFC 6238 that derives a short code from a shared secret and the current time, rotating every 30 seconds.

How do you defend against Time-Based One-Time Password (TOTP)?

Defences for Time-Based One-Time Password (TOTP) typically combine technical controls and operational practices, as detailed in the full definition above.

What are other names for Time-Based One-Time Password (TOTP)?

Common alternative names include: RFC 6238, Time-based OTP.

● Related terms

● See also