TOTP code generator

Make 2FA codes (RFC 6238) from a Base32 secret, with a live countdown.

Do not paste the secret of a real account into a website you cannot check. This page runs in your browser and never stores the secret, but you have to trust it.

Current code

Enter a secret key to see the code.

What this tool does

Most two-factor login codes are TOTP codes: six digits that change every 30 seconds, made from a shared secret and the current time. This tool makes the same codes in your browser. Paste the secret key (written in Base32, the letters A to Z and digits 2 to 7) or a whole otpauth:// link, and it shows the current code with a ring that counts down to the next one, plus the previous and next codes. It is meant for developers who are building or testing two-factor login, for checking that a secret was copied correctly, and for anyone who has a saved secret and needs one code.

How to use it

  1. Type or paste the secret key. Spaces, hyphens, lower case and a trailing = are fine. If the secret has a wrong character, the tool names it and says where it is.
  2. Or paste an otpauth://totp/... link into the second field. It fills in the secret, the algorithm, the digits and the period, and then clears the link from the screen.
  3. Leave the settings alone unless your service says otherwise: SHA-1, 6 digits, 30 seconds is what almost every service and app uses.
  4. Press Copy to copy the code without the space in the middle. Press Example to try the well-known demo secret.

How a code is made

The secret is turned into bytes. The number of whole periods since 1 January 1970 (UTC) becomes an 8-byte counter. An HMAC of the counter with the secret gives a 20-byte value for SHA-1 (32 for SHA-256, 64 for SHA-512). The last four bits pick an offset, four bytes from there are read as a number with the top bit cleared, and the remainder after dividing by one million (for six digits) is the code, padded with leading zeros. This is the dynamic truncation of RFC 4226, and RFC 6238 only changes the counter to a time step.

Here is a check you can reproduce. The RFC 6238 test secret is the text 12345678901234567890, which in Base32 is GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ. At 59 seconds after the epoch the counter is 1, and with SHA-1 and eight digits the code is 94287082. With six digits it is the last six, 287082. At 1111111109 seconds the code is 07081804, with its leading zero. The tests of this tool run the full table of RFC 6238 for all three hashes.

Services describe a secret with an otpauth link, which is what the QR code in the setup screen contains. It can carry an issuer, an account name, the algorithm (SHA1, SHA256 or SHA512), the digits (6 to 8) and the period in seconds. Some apps ignore these options and always use SHA-1, six digits and 30 seconds, so if a code from this tool disagrees with your app, try those defaults. To read the link from a QR image, use the QR code scanner and paste the result here. A link for counter-based codes (HOTP) is recognised and refused, because those codes depend on a counter that only the service knows.

Safety

A TOTP secret is as valuable as a password: whoever has it can produce your codes forever. Do not paste the secret of a real account, such as your bank or your main email, into any website, including this one. This page runs in your browser, does not send the secret anywhere, does not keep it in storage or in the address bar, and forgets it when you close the tab, but you cannot verify that from the outside. Use it for test accounts and development, and keep real secrets in an authenticator app or a password manager. The password generator and the text encryption tool are the right places for other secrets, and the JWT decoder helps with tokens.

When a code is rejected

The code depends on your device clock. If the clock is a minute off, the code belongs to a different step and the service refuses it. Turn on automatic time. The previous and next codes are shown so you can see whether the service is accepting a neighbouring step, which many do to allow for small differences. Also check the secret for a missed character: a wrong secret still gives codes, they are just not the right ones.

Frequently asked questions

Is it safe to paste my 2FA secret here?

For a real account, no website is a good place for it. This page does everything in your browser and does not store or send the secret, but you cannot prove that from outside, and a leaked secret lets someone make your codes. Use it for test and development secrets.

Why does my code not match the app?

Check, in order: the device clock (set the time automatically), the secret (one wrong character gives wrong codes), and the settings. Some apps ignore the algorithm, digits and period of a link and always use SHA-1, six digits and 30 seconds, so choose those in the tool.

What is the difference between TOTP and HOTP?

HOTP (RFC 4226) makes a code from a counter that increases with each use. TOTP (RFC 6238) replaces the counter with the current time divided into steps, 30 seconds by default. This tool makes TOTP codes only.

Which characters can a Base32 secret contain?

The letters A to Z and the digits 2 to 7. The digits 0, 1, 8 and 9 are not used, so they cannot be confused with O and I. Case does not matter, and spaces, hyphens and = padding are ignored.

Are the codes stored or sent anywhere?

No. The secret lives only in the page's memory while it is open. It is not written to local storage, cookies or the address bar, and nothing is sent to a server.

Can it handle counter-based (HOTP) links or Steam codes?

No. A link of type hotp depends on a counter that only the service knows, so the tool names it and refuses it. Steam Guard and a few other services use their own variants of the algorithm, which are not RFC 6238.