CraftTools

TOTP Authenticator Code Generator

Guide: Two-Factor Codes Explained: How TOTP Authenticator Apps Work

Nothing you enter or choose here leaves your device. This tool runs in your browser.

How a six-digit code gets made

A TOTP code (time-based one-time password) looks random, but it comes from a short recipe that your phone and the website both follow. Neither has to talk to the other when the code is made. They only need to share a secret key and agree on the time.

  1. Take the current Unix time in seconds and divide by 30, dropping the remainder. That whole number is the counter. It goes up by one every 30 seconds.
  2. Run the counter through HMAC with the secret key. By default the hash is SHA-1, which gives a 20-byte result.
  3. Use the last four bits of that result to pick a starting spot, read four bytes from there, and clear the top bit. That leaves a number.
  4. Take the last six digits of that number, adding leading zeros if it's short. That's your code.

The rules are written down in RFC 6238, which builds on the older HOTP standard, RFC 4226. Because it's a public standard, one secret gives the same code in Google Authenticator, Microsoft Authenticator, Authy, 1Password and this page.

The secret is written in Base32, which uses only the letters A to Z and the digits 2 to 7. There's no 0, 1, 8 or 9, which is deliberate: it stops you mixing up the letter O with zero or the letter I with one. If a secret you typed by hand contains one of those digits, you've made a typing mistake. Spaces and lowercase are ignored.

When a site shows you a QR code for 2FA, the code holds an otpauth link that carries the secret plus the settings:

otpauth://totp/Example:ada@example.com
  ?secret=JBSWY3DPEHPK3PXP
  &issuer=Example
  &algorithm=SHA1
  &digits=6
  &period=30

Most sites use SHA-1, six digits and 30 seconds, so those are the defaults here. A few use eight digits, a 60-second step or SHA-256. If your code never matches, paste the full link instead of just the secret, so the page picks up the site's own settings.

A test value you can check against

Developers building their own 2FA need a known answer to test with. RFC 6238 publishes one. Take the ASCII text 12345678901234567890 as the secret, which is GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ in Base32. At Unix time 59, with SHA-1 and eight digits, the code is 94287082. With six digits it's the last six of those, 287082. If your code gives something else, the bug is in the counter, the byte order or the truncation step, not in the key.

Why a code gets rejected

  • Wrong clock. A phone or computer that's a minute off makes a code from the wrong 30-second window. Switch on automatic time. Servers usually accept one window either side, so a few seconds of drift is fine.
  • Different settings. The site may use eight digits or another step length. Use the full otpauth link.
  • Typed secret errors. One wrong character gives a completely different code with no hint of what went wrong. Copy and paste the secret instead of retyping it.
  • Code expired mid-typing. If the countdown is nearly out, wait for the next code. Servers often reject a code that has just rolled over.
  • Reused code. Some sites refuse a code that was already accepted once in the same window. Wait for the next one.

Using it safely

This page is handy for testing a 2FA setup you're building, checking that two apps agree, or recovering your bearings when an authenticator behaves oddly. It isn't a place to keep your real secrets. Nothing is saved or sent anywhere, but anyone who has the secret can make your codes, so keep real ones in an authenticator app or a password manager, and keep the backup codes the site gave you somewhere offline.

Compared with codes sent by text message, TOTP can't be intercepted in transit and isn't exposed to SIM swapping. It doesn't stop a convincing fake login page that asks for your code and passes it on in real time, so it's worth checking the address before you type it. The guide to TOTP codes goes through the idea in more detail, and the Base32 encoder converts text to and from the secret format.

Written by Akinrinmade Michael · Updated October 24, 2026

How to use

  1. 1Paste your secret key or otpauth link, or make a random secret.
  2. 2Read the code and the seconds left. Copy it when you need it.
  3. 3Scan the QR code with an authenticator app to set the secret up there too.

Frequently asked questions

Is my secret sent anywhere?

No. Everything happens in your browser, and nothing is sent to us.

What is a TOTP code?

A six-digit code that changes every 30 seconds. Your app and the website both work it out from a shared secret and the time, so they match without talking to each other.

Which apps are compatible?

Any authenticator that follows the standard (RFC 6238), including Google Authenticator, Microsoft Authenticator, Authy and 1Password. The codes here match theirs for the same secret.

Why is my code wrong?

Usually the device clock is off, or the site uses other settings such as 8 digits or a 60 second step. Open the settings, or paste the full otpauth link, which carries them.

Should I keep my real secrets here?

No. This page doesn't save anything, so close it when you're done. Keep real secrets in a proper authenticator app or password manager.

Can I use this to log in to my accounts?

You can, since the codes match your authenticator app for the same secret. It's better kept for testing, though. A real secret belongs in an authenticator app or a password manager, not in a browser tab.

Why does a secret never contain 0, 1, 8 or 9?

Secrets are written in Base32, which uses A to Z and 2 to 7. Leaving out those digits stops you mixing up letters and numbers that look alike.

Read the guide

Learn how this works and how to get the most from it.

Security

Two-Factor Codes Explained: How TOTP Authenticator Apps Work

How the six-digit codes in authenticator apps are made, why they change every 30 seconds, what the secret key is, and how to set one up safely.

3 min read

Base32 Encoder / Decoder

Encode and decode Base32, including hex and Crockford.

QR Code Generator

QR codes for links, Wi-Fi, contacts, email, phone and text. PNG or SVG.

Password Generator

Create strong random passwords or passphrases, one or many at a time.

UUID & Random Number Generator

Generate secure UUIDs (v4, v7) and random numbers.