Random passwords from letters, digits and symbols via crypto.getRandomValues.
TOTP/HOTP Code Generator
Use TOTP/HOTP Code Generator
What it does
Compute time-based (TOTP) or counter-based (HOTP) one-time passwords for a Base32 secret, the way authenticator apps do, and check whether a code matches. Useful for testing your own 2FA setup.
It runs entirely in your browser: nothing you enter is uploaded.
How to use TOTP/HOTP Code Generator
- Enter the secret. Paste the Base32 secret of your own test account into Secret key (Base32), or press Random for a new 32-character secret.
- Match your app's settings. Choose the Code type (TOTP time-based or HOTP counter-based), the Algorithm and the number of Digits. Most authenticator apps use TOTP, HMAC-SHA-1 and 6 digits.
- Show the code. For TOTP press Start TOTP: the code appears with a countdown and is recomputed every second. For HOTP set the counter and press Show HOTP code; Next moves to the following counter.
- Check a code. Type a code from your app or a server into Verify a code and press Verify. The verdict says whether it matches and for which time step or counter.
- Stop and clear. Press Stop when you are done; the last code stays on screen. Empty the secret field yourself.
Example
RFC 6238 test secret
GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ412568This is the published RFC 6238 test key 12345678901234567890 in Base32. The page shows its current six-digit code and the seconds until the next one, the same code an authenticator app shows for this secret; switched to HOTP with counter 0 it shows 755224, the first RFC 4226 test value.
What it checks
| Signal | What it means |
|---|---|
| The code | HMAC of the time step (TOTP) or the counter (HOTP), cut to 6 or 8 digits as in RFC 4226 and RFC 6238. It matches an app only when the type, algorithm and digits are the same. |
| Refreshes in Ns · time step N | Seconds left in the current 30-second window and the step number, taken from your device clock. A clock that is off shows the previous or next code. |
| Counter N · press Next | In HOTP mode the code belongs to that counter. Each code is used once; servers then expect the next counter. |
| Not Base32: ... | The secret contains characters outside A–Z and 2–7, such as 0, 1, 8 or 9. Spaces, hyphens and = are ignored and lowercase letters are accepted. |
| secret is only N bits | The secret is shorter than the 128 bits (26 Base32 characters) RFC 4226 asks for. Codes are still shown, but such a secret is easier to guess. |
| Valid: matches ... | Verify found the code for the current time step or the HOTP counter in the field. |
| Valid for the previous or next step | The code belongs to one 30-second step before or after now (shown in amber). Usually a small clock difference between the two devices. |
| No match | Neither the checked time steps nor the counters fit. Check the secret, the clock, the algorithm and the number of digits. |
More examples
RFC 4226 test key, HOTP
GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQWith Code type HOTP, HMAC-SHA-1, 6 digits and counter 0 the code is 755224; Next gives 287082 for counter 1, the published RFC 4226 test values.
Verify a code one counter ahead
GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQIn HOTP mode with counter 0, typing 287082 into Verify a code gives: Valid for counter 1, 1 ahead of the counter field.
Not a Base32 secret
0189ERROR with the message Not Base32: “0”, “1”, “8”, “9”, because Base32 uses only the letters A–Z and the digits 2–7.
FAQ
What exactly does it compute?
TOTP codes from the current time in 30-second steps (RFC 6238) or HOTP codes for a counter you set (RFC 4226), with HMAC-SHA-1, SHA-256 or SHA-512 and 6 or 8 digits; most authenticator apps use SHA-1 and 6 digits. Verify a code tries the current time step and one step either side, or the HOTP counter and the next 9, and a secret with characters outside A-Z and 2-7 is rejected with a message.
Does a TOTP code protect me from phishing?
Not fully. Adversary-in-the-middle phishing kits pass the code to the real site as you type it, so it is captured together with the password; passkeys and FIDO2 security keys resist this because they are tied to the real domain.
Is the secret sent or stored anywhere?
No. Codes are computed in your browser with the Web Crypto API and the secret is never uploaded or saved. TOTP depends on your device clock, so a clock that is off gives different codes.
How can I check the codes against the RFCs?
Use the test key 12345678901234567890, in Base32 GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ. In HOTP mode counter 0 gives 755224 and counter 1 gives 287082 (RFC 4226). RFC 6238 lists 94287082 for 8 digits at 59 seconds after 1 January 1970 UTC; the TOTP mode always uses the current time.
What is the difference between TOTP and HOTP?
HOTP (RFC 4226) counts uses: each code belongs to a counter that goes up by one. TOTP (RFC 6238) is HOTP with the counter set to the current 30-second time step, so the code changes with the clock.
Why does my app show a different code?
Check the clocks first, because 30 seconds of difference changes the code. Then check the secret for typos and whether the account uses SHA-256, SHA-512, 8 digits or a counter instead of time, and set the same options here.
Should I paste a real 2FA secret here?
Avoid it. The secret stays in your browser, but anyone who sees or copies it can produce your codes until you reset 2FA on that account. To move 2FA to a new phone, use the account's own transfer or reset option.