TOTP / 2FA Code Generator
Generate and verify TOTP codes (RFC 6238) entirely in your browser. Use for testing 2FA flows, not for production secrets.
TOTP Generator Tool
Generate a fresh random base32 secret + otpauth:// URI you can scan into Google Authenticator, 1Password, Authy, or any other TOTP app. The URI uses the algorithm, digits, and period selected in the Generate tab (defaults: SHA-1, 6 digits, 30 s).
How to use the TOTP generator
Generate code mode
Paste a base32 secret (e.g. the QR-secret your 2FA-enabled service shows when setting up authenticator apps). The current code updates live every second, with the previous and next-window codes shown for drift testing.
Verify code mode
Paste a secret and a code, click Verify, and see whether the code matches the current 30-second window or one window before/after (the RFC 6238-recommended drift tolerance, commonly implemented).
New secret mode
Generate a brand-new 160-bit random base32 secret plus the standard otpauth:// URI containing it. The URI is what you'd encode into a QR code for scan-to-add into Google Authenticator, 1Password, Authy, etc.
Test, but don't use in production
This tool is for testing TOTP flows, learning the protocol, and verifying your integration. Don't paste real production secrets into any browser tool — use a hardware authenticator or a dedicated password manager for live accounts.
TOTP — how time-based one-time passwords actually work
TOTP (Time-based One-Time Password) is the standard powering almost every "scan this QR code into your authenticator app" two-factor authentication flow on the modern web. Specified in RFC 6238 in 2011, it generates a fresh 6-digit code every 30 seconds from a shared secret known only to the user's authenticator app and the service's server. The codes are deterministic given the same secret and the same time — meaning Google's server and your Google Authenticator app independently compute the same digit string, without ever exchanging the code itself over the network. Loss of network connectivity does not break TOTP; only loss of clock sync does.
The algorithm in one paragraph
TOTP is HOTP (HMAC-based One-Time Password, RFC 4226) with the counter replaced by floor(unix_time / 30). The server and client both compute HMAC-SHA1 over that counter using the shared secret, then take the last byte of the HMAC output, mask off the high bit, and use the result as an offset to extract 4 bytes from the HMAC. Those 4 bytes are interpreted as a 31-bit integer modulo 10⁶ to produce the 6-digit code. The entire computation is around 20 lines of JavaScript when SubtleCrypto handles the HMAC primitive for you. The current standard supports SHA-1, SHA-256, and SHA-512 variants; SHA-1 remains the default for compatibility with older authenticator apps.
Drift tolerance and the 30-second window
Real-world clocks aren't perfectly synchronised. A phone's clock might be a few seconds ahead or behind the server. A user might also start typing a code with 28 seconds left on the timer and finish typing 5 seconds after the window rolled over. To handle these, RFC 6238 §5.2 recommends that "at most one time step is allowed as the network delay" — the ±1-window tolerance commonly implemented, giving an effective 90-second acceptance band. The RFC leaves the exact out-of-sync limit to each validator, which can set it tighter or looser both forward and backward depending on its risk model.
Regulators and authenticator apps
Authenticator apps are widely accepted as a strong second factor for online banking and payment services — and because TOTP is an open standard, any RFC 6238-compliant app can serve that role.
What this tool is not
This is a learning / testing / integration-verification tool. It is not a production authenticator app. Paste a Google account's TOTP secret into this page and you have effectively stored that secret in your browser's tab memory — accessible to any browser extension with content-script permission, any cross-site-scripting vulnerability on any other page in the same browser session, and any malware capturing the page's DOM. For real accounts, use a dedicated authenticator app (Google Authenticator, Authy, 1Password, Bitwarden's built-in TOTP) or a hardware key (YubiKey). The tool above is for verifying that your server's TOTP implementation produces codes matching what the standard authenticator app would produce — a debugging tool, nothing more.
10 TOTP / 2FA facts
TOTP was specified in RFC 6238 in 2011 and is HOTP (RFC 4226) with the counter replaced by floor(unix_time / 30). The two RFCs together fit in under 30 pages.
The time step is configurable via the period parameter in the otpauth:// URI. 30 seconds is the RFC 6238 default, selected "as a balance between security and usability".
RFC 6238 §5.2 recommends that "at most one time step is allowed as the network delay" — the ±1-window drift tolerance commonly implemented, an effective 90-second acceptance band for 30-second codes.
The base32 alphabet (RFC 4648) is used for TOTP secrets because it's case-insensitive and avoids the 0/O and 1/l visual collisions of base64 — important for manual entry from printed setup pages.
RFC 4226 (R6) sets the secret length: it MUST be at least 128 bits, with 160 bits (20 bytes / 32 base32 characters) RECOMMENDED. This tool's new-secret mode generates 160-bit secrets.
TOTP is an open standard: any RFC 6238-compliant app produces the same codes from the same secret, so you are never locked into one vendor’s authenticator.
SHA-1 is still the default TOTP algorithm despite SHA-1's general collision weaknesses — HMAC-SHA1's security model doesn't rely on collision resistance, so it remains safe for TOTP.
Microsoft Authenticator, Google Authenticator, 1Password, Authy, and Bitwarden all implement the same RFC 6238 standard. A TOTP secret from one works in any of them.
The otpauth:// URI scheme was created by Google specifically for the QR-code flow. It's not an IETF standard but every major TOTP app supports it.
NIST SP 800-63B classifies SMS/voice OTP as RESTRICTED — still permitted, but with extra obligations on the provider (risk notice, a non-restricted alternative, a migration plan). The 2025 revision (800-63B-4) retains the restriction and classifies all manually entered OTP, TOTP included, as not phishing-resistant.
Frequently asked questions
floor(unix_time / 30), so the code rotates automatically every 30 seconds without user interaction. TOTP is by far the more common variant today.otpauth://totp/Issuer:account?secret=BASE32&issuer=Issuer&algorithm=SHA1&digits=6&period=30. The path part contains the account label, the query string contains parameters. Encoding this as a QR code is what enables scan-to-add into authenticator apps.Digit parameter allows 6, 7, or 8-digit codes — 6 is the required minimum. The digits parameter belongs to the otpauth:// URI convention, which documents values of 6 or 8. In practice 6 is overwhelmingly the standard.Related News
You may be interested in these recent stories from our newsroom.
-
Pichai Promised Gemini 3.5 Pro in June. Google Shipped Three Flash Models.
Alphabet entered September on its longest monthly losing streak since 2015. Flash is the small tier, and shipping three of them is not the f...
-
Dell's $95bn AI Backlog Exceeds Its $74bn Full-Year AI Guidance
Record revenue of $47bn and $60.9bn of AI orders against $16.4bn recognised. The order queue grew by about $44bn in three months, and full-y...
-
Moonshot's $50bn Valuation Is the Smallest of China's Three Model Labs
The Hong Kong filing seeks about $3bn. DeepSeek is marked near $74bn and Z.AI near $66bn, and the $50bn figure came from a private round rat...
Pick up where you left off
Stored only in this browser — never sent to our servers.