Generate two-factor codes from a TOTP secret

Generate time-based one-time passwords from a base32 secret or otpauth link, with SHA-1, SHA-256 or SHA-512 and 6 or 8 digits. The secret stays on your device.

How to generate a TOTP code

  1. 1

    Paste the base32 secret or the otpauth link

  2. 2

    Check the algorithm and digits

  3. 3

    Press Show the code and use it before it expires

One-time codes worked out on your device

Two-factor sign-in apps show a six-digit code that changes every 30 seconds. The code is worked out from a shared secret and the time, by the TOTP algorithm in RFC 6238, so anything that knows the secret can make the same code. This page does that, in your browser, for testing a 2FA setup you are building or checking a secret you hold.

How the code is made

The time is divided into steps, 30 seconds long by default, counted from 1 January 1970. The step number goes through HMAC with the secret as the key, which is HOTP from RFC 4226: four bytes are picked from the result, and the last six or eight decimal digits of that number are the code. SHA-1 is the default in the otpauth key format, and RFC 6238 also defines SHA-256 and SHA-512.

The result shows the current code, the seconds it has left, and the previous and next codes, since RFC 6238 suggests a server accept at most one step either side, to allow for clock drift and network delay. Press the button again for a fresh code once the time runs out.

A secret is base32: the letters A to Z and the figures 2 to 7, often shown in groups of four. Case, spaces, hyphens and trailing = signs are ignored. An otpauth://totp/ link, the text inside an authenticator QR code, is read whole: the secret, the issuer and account name, and the algorithm, digits and period if it states them. The page’s own settings apply where the link is silent. Counter-based (HOTP) links are refused, since their code depends on a counter the page cannot know.

Keep the secret safe

Anyone with the secret can make your codes, so it deserves the care of a password. Nothing on this page sends, stores or logs it, and closing the tab forgets it. Prefer test secrets, and the RFC’s own, when trying the tool.

Nothing is uploaded. The code is worked out in this tab.

Everything you need

Secret or otpauth link

Base32 in any case with spaces or hyphens, or the full otpauth:// link from a QR code.

All RFC 6238 settings

SHA-1, SHA-256 or SHA-512, 6 or 8 digits, any period, checked against the RFC's own test values.

Private by design

The secret never leaves this page; the HMAC runs in your browser.

Nothing uploaded: open the Network panel while it runs and check.

No daily limits or watermarks: free batches take up to 20 images.

Works offline: once the page has loaded, on any current browser.

Frequently asked questions

Is it safe to paste my secret here?

The secret is read by this page and the code is worked out with your browser's own HMAC; nothing is sent, stored or logged. Even so, a 2FA secret is as sensitive as a password. Paste a real one only on a device you trust, and use this mainly for testing your own app's 2FA or recovering a code you set up yourself.

Why does my code not match my authenticator app?

Check the device clock first, since a code depends on the time to the second. Then check the settings. The otpauth key format defaults to SHA-1, 6 digits and 30 seconds, and a link states any that differ. The page also shows the previous and next codes, since RFC 6238 suggests a server allow a step either way for clock drift.

Where do I find the secret?

When you turn on two-factor sign-in, the service shows a QR code and usually a "can't scan it?" link with the secret as letters and figures. The QR code itself holds an otpauth link, which this page reads too, issuer and account included.

Can it make codes for a past or future time?

Yes. Type a Unix time, in seconds since 1970, in the time box. That is how the RFC 6238 test values are checked, and it is useful when testing a server's handling of clock drift.

Sources

Related guides

Work with files privately and confidentlyPractical, sourced explanations for safer file conversion, sharing, and cleanup.