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 + standard otpauth:// URI you can scan into Google Authenticator, 1Password, Authy, or any other TOTP app.
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 standard drift tolerance most services accept).
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 recommends accepting codes from the immediately-previous and immediately-next 30-second windows as well as the current one. Most major services (Google, AWS, Microsoft 365, GitHub) implement this drift tolerance of ±1 window — giving an effective 90-second acceptance band. Some banking and high-security services tighten this to ±0 (current window only) or use ±2 (150-second band) depending on their risk model.
Why MAS and BNM mandates matter for ASEAN fintech
Singapore's Monetary Authority (MAS) requires two-factor authentication for retail banking and licensed payment services under MAS Notice 644 and the Technology Risk Management Guidelines. Malaysia's Bank Negara has equivalent requirements via the eKYC and RMiT (Risk Management in Technology) guidelines. Both regulators accept TOTP via authenticator apps as a compliant second factor — alongside SMS-OTP and hardware tokens. Singapore's Singpass MFA architecture uses a custom proprietary scheme, but most ASEAN consumer-fintech and e-wallet products (GrabPay, ShopeePay, Touch 'n Go) rely on TOTP behind the scenes for their backend service authentication, even when the consumer-facing factor is biometric or SMS-OTP.
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 default 30-second window is configurable via the period parameter in the otpauth:// URI. 60 seconds is occasionally used by services that want fewer reads against backing crypto hardware.
Most major services accept codes from the current ±1 30-second window — effectively a 90-second drift tolerance. AWS GovCloud and some banking services tighten this to ±0.
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.
The standard secret length is 160 bits (20 bytes / 32 base32 characters). Google generates 80-bit secrets (10 bytes / 16 base32 characters) — slightly weaker but still well above brute-force feasibility.
MAS Singapore and BNM Malaysia both accept TOTP authenticator apps as a compliant second factor for retail banking. Many regional fintechs run TOTP backstage even when the user-facing factor is biometric.
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.
SIM-swap attacks have made SMS-OTP increasingly risky. NIST SP 800-63B recommends authenticator apps (TOTP / push) over SMS for any account with material risk.
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.digits parameter. 6 is overwhelmingly the standard; 8 is occasionally seen in higher-security contexts. Most consumer authenticator apps don't display 7-digit codes at all.Related News
You may be interested in these recent stories from our newsroom.
-
Snowflake jumps 36 per cent in a day on an earnings beat and a US$6 billion AWS chip deal
Snowflake had its best day as a public company on 28 May, closing up 36 per cent after a clean first-quarter beat and a five-year, US$6 bill...
-
MAS Scraps Mandatory Financial Advice for Most Complex Product Buyers in Retail Shake-Up
Singapore retail investors buying structured notes, derivatives and investment-linked policies will no longer need mandatory financial advic...
-
SEC Rewrites Float Rules, PSE Moves to Implement Them — Clearing the Path for GCash's USD 1B Philippine IPO
The SEC lowered the public float floor for large Philippine issuers in February 2026. The PSE followed with a consultation paper in April. T...
75 more free tools
Calculators, converters, security tools — no signup.