TOTP Code Generator
Generate a 6-digit TOTP one-time code from a Base32 secret.
What is TOTP Code Generator
TOTP (Time-based One-Time Password) generates a 6-digit code that changes every 30 seconds from a shared secret and current time (RFC 6238), used for two-factor authentication.
🔒 Everything runs in your browser. Nothing is uploaded.
What this tool actually does with your file
- Where it runs
- In your browser, on this page
- Upload
- None — the file never leaves your device
- Offline
- Works with the network disconnected
RFC 6238, computed from a shared secret and the clock
The secret is Base32-decoded, concatenated with a counter derived from Unix time divided by the period (30 seconds by default), then HMAC-SHA1 is applied and the result is dynamically truncated to six digits. Both sides compute the same six digits from the same two inputs, which is why no network call is involved.
SHA-1 is not a weakness here. HMAC-SHA1 remains sound for this construction, and it is what every authenticator app implements — switching to SHA-256 would produce codes that Google Authenticator rejects. The algorithm is fixed by interoperability, not by preference.
Why codes are rejected when the secret is right
Clock drift is the usual cause. Servers accept the current window plus typically one before and one after, which tolerates about 90 seconds of skew. A device more than a minute off will fail intermittently, which looks like a wrong secret rather than a wrong clock.
The second cause is the secret itself. Base32 secrets are printed in four-character groups and often contain characters that look alike; dropping one group yields a shorter but structurally valid key that produces consistently wrong codes. Compare the decoded byte length against the original — 20 bytes (160 bits) is the common size.
Handling the secret
The secret is the second factor. Anyone with it can generate valid codes forever, so it deserves the same care as a password: not in screenshots, not in a ticket, not in a chat message. This page computes in the tab and transmits nothing, but the clipboard and the screen are still exposure.
If a secret may have leaked, the fix is to re-enrol the account and invalidate the old secret, not to change the password. Recovery codes are the way back in when the device is lost — store them somewhere that is not the same device.
How to use it
- 1.Enter the Base32 secret
- 2.Check the period
- 3.Enter the code in the auth screen
How TOTP Code Generator works under the hood
Generators here produce values locally with the browser's cryptographic random source. The output is generated on your device, not issued by a server, so there is no record of what was generated.
- 1
Seed from the platform CSPRNG
Values come from crypto.getRandomValues, not Math.random, so they are suitable for passwords and tokens.
- 2
Map to the requested alphabet
Random bytes are mapped to the chosen character set while rejecting values that would bias the distribution.
- 3
Render on the page
The result is shown and can be copied; it is not stored or sent.
Processing pipeline
Strength comes from length and source
A 20-character password from a 90-symbol alphabet has far more entropy than a 12-character one, and both are only as good as the random source. This site uses the platform CSPRNG, so the remaining risk is reuse, not generation.
Nothing is logged
Generated values are never transmitted, so there is no server log, no history and no recovery. Save what you need before closing the tab.
Verify it yourself
Generation is local. Reload the page and the values are gone.
- 1.Open DevTools on this page and switch to the Network tab
- 2.Keep the filter on Fetch/XHR and run the tool
- 3.Confirm no request carries your file — you should see only page assets and fonts
Frequently asked questions
Where do I get the secret?
Use the Base32 string (A-Z, 2-7) shown when setting up two-factor authentication.
How long is a code valid?
30 seconds by default. A new code is generated automatically after that.
Is the secret uploaded?
No. HMAC-SHA1 is computed entirely in your browser.
More in Generators
On this page
- What is TOTP Code Generator
- What this tool actually does with your file
- How it actually behaves
- How to use it
- How it works inside
- Frequently asked questions
Excel formula reference
29 functions with syntax, arguments and a table you can retype.
Browse the list →