Skip to content
wonderstacked

TOTP Generator

Generate and verify 2FA codes, and make authenticator QR codes.

Runs in your browser
Loading TOTP Generator…

How does a TOTP generator work?

A TOTP generator makes the six-digit codes used for two-factor authentication from a shared secret and the current time. This TOTP generator can create a new secret with a QR code for an authenticator app and check whether a code is valid.

Time-based one-time passwords (RFC 6238) combine a secret and the current 30 second time step through HMAC to produce a short code. The server and your app hold the same secret, so both calculate the same code without sending it. It is the method behind most authenticator apps.

The tool generates codes from a secret you enter, creates a new random secret with a otpauth QR code you can scan into an authenticator app, and verifies a code against a secret, allowing a small clock drift. You can choose SHA-1, SHA-256 or SHA-512, 6 or 8 digits, and the period.

Everything runs in your browser. Do not paste the secret of an account you rely on into any web page; use it for testing your own implementation or for accounts you can reset. A TOTP code only proves possession of the secret, not who you are.

Page updated .

How to use the TOTP Generator

  1. Enter a base32 secret, or create a new one.
  2. Scan the QR code with an authenticator app, or read the current code.
  3. Enter a code in the verify box to test it against the secret.

Examples

RFC 6238 test
Input
Secret GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ, time 59 s
Output
Code 94287082 (8 digits, SHA-1), matching the RFC test vector
Verify
Input
A code from your app
Output
Valid, within one time step of drift

Tips

  • Check your device clock: a code that never verifies is nearly always a time mismatch.
  • Store the secret or backup codes safely; losing the secret locks you out.
  • Most apps use SHA-1, 6 digits and 30 seconds, so keep these defaults unless your service says otherwise.

Specs & limits

Standard
RFC 4226 and RFC 6238
Algorithms
SHA-1, SHA-256, SHA-512
Digits
6 or 8
Period
Configurable, 30 seconds default
Processing
WebCrypto in your browser

Troubleshooting

›Code never matches

Cause: Clock drift or wrong settings.

Fix: Sync the device time and match algorithm and digits.

›QR code does not scan

Cause: Low contrast or small size.

Fix: Enlarge it or enter the secret manually.

›Invalid secret error

Cause: The string is not valid base32.

Fix: Use letters A to Z and digits 2 to 7 only.

Frequently asked questions

›What is a TOTP secret?

A random base32 string shared between you and the service. Anyone who has it can generate your codes.

›Why does my code not verify?

Usually the clock is out of sync, or the algorithm, digits or period differ from the setup.

›What is the difference between TOTP and HOTP?

HOTP uses a counter; TOTP uses time, so its codes change every period.

›Is it safe to use here?

The code runs locally. Still avoid entering real account secrets; use it for tests.

›Can I use the QR code with Google Authenticator?

Yes. The QR code uses the standard otpauth format that authenticator apps accept.

›Does it work offline?

Yes, once the page is loaded the calculation needs no network.

More security tools

See all
esc