What is TOTP? (and TOTP vs HOTP)
TOTP stands for Time-based One-Time Password. It's the algorithm behind the 6-digit codes in Google Authenticator and almost every authenticator app, defined in RFC 6238.
Updated 2026-11-19
TOTP meaning
A time-based one-time password is a short code calculated from two inputs: a shared secret key and the current time. The server and your app both know the key and the time, so they calculate the same code without talking to each other.
How a TOTP code is generated
- Take the current Unix time and divide it by the period (usually 30 seconds). The whole number is the counter.
- Calculate HMAC-SHA1 (or SHA-256/SHA-512) of the counter using the secret key.
- Pick 4 bytes from the result (“dynamic truncation”) and turn them into a number.
- Keep the last 6 (or 8) digits. That's the code.
Because the counter changes every 30 seconds, the code does too. That's why a wrong device clock makes codes fail.
TOTP vs HOTP
| TOTP | HOTP | |
|---|---|---|
| Moving factor | Time (every 30 s) | A counter that goes up on each use |
| Standard | RFC 6238 | RFC 4226 |
| Code expires | Yes, after the period | No, until the next one is used |
| Typical use | Authenticator apps, 2FA on websites | Hardware tokens with a button |
TOTP is really HOTP with the time as the counter, which makes codes short-lived and harder to reuse.
TOTP secret and QR code
The secret is usually a Base32 string (letters A–Z and digits 2–7). Sites share it as a QR code containing an otpauth://totp/…?secret=… link, which can also set the algorithm, digits and period.
Generate a TOTP code
- Get2FA: paste a TOTP secret and get the current code (and the next one), right in your browser.
- TOTP key & QR generator: create a new secret and its QR code for testing.
- Code checker: see whether a code matches a key and whether your clock is off.
Guides
- What is 2FA (two-factor authentication)?
- Where to find your 2FA secret key
- How to turn on Instagram 2FA with an authentication app
- How to set up Facebook 2FA with an authenticator app
- How to transfer Google Authenticator to a new phone
- 2FA code not working? Here's how to fix it
- Lost your phone with the authenticator app? What to do
- “Enter a 6-digit login code generated by an authentication app”: what to do
- Fortnite 2FA: how to enable it at fortnite.com/2fa
- Microsoft Authenticator not showing a code? Here's the fix
- How to set up Amazon Two-Step Verification with an authenticator app
- How to turn on PayPal 2-step verification with an authenticator app
- How to set up Coinbase 2FA with an authenticator app
- How to enable Discord 2FA with an authenticator app
- How to set up X (Twitter) 2FA with an authentication app
- How to set up TikTok 2-step verification with an authenticator app
- How to use any authenticator app with your Microsoft account
- How to set up GitHub 2FA with a TOTP app
- How to enable Binance 2FA with an authenticator app