TOTP / 2FA Authenticator Code Generator
Turn a Base32 secret into the live 6- or 8-digit authenticator code your 2FA app would show right now — with a countdown to the next code — or generate a fresh secret plus a scannable QR to set up two-factor authentication. RFC 6238, runs entirely in your browser.
How it works
A time-based one-time password (TOTP) is HOTP evaluated at a clock-derived counter. This tool follows the two standards exactly — RFC 6238 for the time step and RFC 4226 for the HMAC and truncation — computing everything locally with the browser's Web Crypto API. The secret never leaves your device.
- Decode the secret. The Base32 string (RFC 4648 §6, alphabet A–Z and 2–7) is decoded to the raw key bytes
K. Lower-case, spaces, hyphens and=padding are tolerated. - Compute the time step.
T = floor((now − T0) / X)withT0 = 0andX = period(default 30 s). T is encoded as an 8-byte big-endian integer. - HMAC.
H = HMAC-Hash(K, T), where Hash is SHA-1, SHA-256 or SHA-512. This is a 20-, 32- or 64-byte value. - Dynamic truncation (RFC 4226 §5.3). Let
offset = H[last byte] & 0x0F. Take the 4 bytes at that offset and mask the top bit:binCode = (H[offset] & 0x7F)≪24 | H[offset+1]≪16 | H[offset+2]≪8 | H[offset+3]. - Reduce to digits.
OTP = binCode mod 10^digits, left-padded with zeros. For 6 digits that ismod 1,000,000.
The derivation panel inside the tool shows every one of these intermediate values for the current code, so you can line them up against your own implementation byte for byte. On load, the tool also recomputes the official RFC 6238 Appendix B test vectors for SHA-1, SHA-256 and SHA-512 and confirms each matches — that is the “RFC 6238 verified” badge. To create a new account, the “New secret + QR” tab draws a 160-bit key from crypto.getRandomValues and assembles a Google Key-Uri-Format otpauth://totp/… URI rendered as a QR code.
Worked examples
Frequently asked questions
Sources & references
- RFC 6238 — TOTP: Time-Based One-Time Password Algorithm (time step, Appendix B test vectors)
- RFC 4226 — HOTP: HMAC-Based One-Time Password Algorithm (HMAC + dynamic truncation)
- RFC 4648 — Base32 Data Encoding (secret decoding, §6)
- Google Authenticator — Key Uri Format (otpauth:// QR layout)
The algorithm on this page was last cross-checked against the RFC 6238 Appendix B test vectors (SHA-1, SHA-256 and SHA-512) and the otplib/pyotp demo-secret value on 2026-07-15. The check re-runs in your browser every time the tool loads.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.