Skip to content

2FA generator: live TOTP codes from a secret key

Paste the secret key behind a two-factor login, the Base32 text or the otpauth:// link shown next to the QR code when you set up 2FA, and this page shows the same six or eight digit code an authenticator app would show, with a countdown to the next one. Use it to test a 2FA setup you are building, to check that a backed-up secret still works, or to understand how the codes are made. The code is calculated in your browser and the secret is never sent to us.

Quick answer

Paste a Base32 secret or an otpauth:// link. The current code appears at once with the seconds it has left; copy it before the bar runs out. Change the algorithm, digits or period only if the service uses non-default settings.

Based on RFC 6238: TOTP: Time-Based One-Time Password Algorithm, IETF, May 2011 · Page updated 23 October 2026

Editor: Abuzar, founder of NeedMyToolsHow we check facts

Everything stays in your browser: the secret is never sent or logged. This is for testing a 2FA setup, checking a backup or learning. A 2FA secret is as sensitive as a password, so keep it private and use real account secrets only on a device you trust.

Letters A-Z and digits 2-7, at least 16 characters. Spaces, hyphens and lower case are fine.

Most services use SHA-1, 6 digits and 30 seconds. A pasted otpauth link sets these for you.

Current code

Paste a secret key or otpauth link to see the live code.

How to use the 2FA Code Generator (TOTP)

  1. Paste the secret key (letters A to Z and digits 2 to 7) or the full otpauth://totp/ link into the box. Spaces and lower case are fine.
  2. Leave SHA-1, 6 digits and 30 seconds unless the service says otherwise; a pasted otpauth link sets these for you.
  3. Read or copy the code before the countdown ends. The previous and next codes help when a clock is a little off.

How a 2FA code is made

Time-based one-time passwords are defined in RFC 6238, published by the IETF in May 2011, and build on the counter-based HOTP method in RFC 4226 from December 2005. The service and your app share a secret key. Every 30 seconds the current Unix time is divided by the period to give a step number; the step is signed with HMAC using the secret, four bytes are picked out of the result by a rule called dynamic truncation, and the number is cut to six or eight digits. Because both sides know the time and the secret, they arrive at the same code without talking to each other. Nothing about the code reveals the secret, and a code is useless once its step has passed.

Secret keys and otpauth links

When you turn on two-factor login, the service shows a QR code. Inside it is a link that starts with otpauth://totp/, followed by a label with the service and account name and a secret parameter written in Base32, the alphabet A to Z plus 2 to 7 defined in RFC 4648. Optional parameters set the algorithm, the number of digits and the period; when they are missing, SHA-1, six digits and 30 seconds are assumed. The "can't scan?" option on most setup screens shows the same Base32 secret as text. Paste either form here. Counter-based HOTP links are not supported, because each code there depends on a counter only your app knows.

Keep the secret private

The secret is the second factor itself: anyone who has it can make your codes forever, until you turn 2FA off and on again. Use this page for testing, for checking a backup, or for learning, on a device you trust, and do not paste the secrets of important accounts into any website you do not control. Here the code is computed with the Web Crypto API in your browser and nothing is sent or logged; the secret is not stored unless you tick Remember, which keeps it in this browser's local storage only until you untick it. The random secret button makes a new 160-bit key, the length RFC 4226 recommends, which you can scan into an app to try a setup end to end.

When the code is rejected

The most common cause is the clock. The code depends on the time, so a phone or computer whose clock is a minute off produces codes the service does not accept; turn on automatic time in your device settings. RFC 6238 lets services accept a code from a step or two around the current one to allow for drift, which is why the previous and next codes are shown. Other causes are a mistyped secret (the letter O and the digit 0 are not both valid Base32), a service that uses SHA-256 or eight digits, or a 60-second period. Check what the setup screen or otpauth link says and match it here.

Sources and related tools

We read the specifications on 23 October 2026 and checked this generator against every test value they publish: the ten HOTP codes in Appendix D of RFC 4226 and the eighteen SHA-1, SHA-256 and SHA-512 codes in Appendix B of RFC 6238. To protect the accounts behind your codes, start with a strong unique password from our password generator, check it with the password breach checker, and keep backup codes somewhere safe.

Frequently asked questions

How does a 2FA generator make TOTP codes?

It signs the current 30-second time step with HMAC and your secret key, as RFC 6238 describes, then shortens the result to six or eight digits. Your authenticator app does the same sum, so both show the same code.

Why does my 2FA code not work?

Usually the device clock is off. Turn on automatic date and time and try again. If it still fails, check that the secret was copied exactly and that the algorithm, digits and period match the service.

Is it safe to paste a 2FA secret into a website?

Only where you trust the page and the device. This page computes the code in your browser and sends nothing, but the secret is as sensitive as a password, so use real account secrets only for testing or backup checks.

What is the difference between TOTP and HOTP?

HOTP (RFC 4226) makes each code from a counter that goes up on every use. TOTP (RFC 6238) uses the time instead of a counter, so codes change every 30 or 60 seconds. This page makes TOTP codes.

Can I move my 2FA codes to a new phone with this?

If you saved the secret or otpauth link when you set up 2FA, you can show its QR code here and scan it with the new app. Without the secret, use the service's own recovery or backup codes instead.