TOTP Generator

Paste a 2FA secret or an otpauth:// link to get the current code and the next one. Computed in your browser: the secret is never sent.

RFC 6238 TOTP and RFC 4226 HOTP · HMAC in Web Crypto · nothing sent, nothing stored

SettingsTOTP · SHA-1 · 6 digits · 30 s
Type
Algorithm
Digits
Period

For plain secrets. An otpauth:// link carries its own settings.

Computed in your browser with Web Crypto. The secret never leaves this page and never goes into a URL.

Checking your device's clock…

What is TOTP?

TOTP (time-based one-time password, RFC 6238) turns a shared secret and the current time into a short code: the same secret and the same 30-second step give the same code on your phone and on the server.

The clock is cut into steps: T is the Unix time divided by 30, rounded down. The code is HOTP (RFC 4226) with T as the counter: an HMAC-SHA-1 of T keyed with the secret, cut to 31 bits at an offset the last byte chooses, then the last 6 digits. Nothing is sent between the phone and the server: both just compute.

The figure is RFC 6238's own test key at 00:00:59 UTC, one of the moments the RFC lists: it is step 1, and the code is the RFC's published value. The tool runs the same computation in your browser.

30-second steps since 1 January 1970

  1. Step 00–29 s755 224
  2. Step 130–59 s287 082
  3. Step 260–89 s359 152
  4. Step 390–119 s969 429

HMAC-SHA-1 of step 1, keyed with the secret

  1. 75
  2. a4
  3. 8a
  4. 19
  5. d4
  6. cb
  7. e1
  8. 00
  9. 64
  10. 4e
  11. 8a
  12. c1
  13. 39
  14. 7e
  15. ea
  16. 74
  17. 7a
  18. 2d
  19. 33
  20. ab
  1. The last byte's low 4 bits: offset 110xab → 11
  2. 4 bytes from the offset, top bit cleared: 1,094,287,0820xc1397eea
  3. Its last 6 digits: the code287 082
RFC 6238's test key (ASCII “12345678901234567890”) at 1970-01-01 00:00:59 UTC: the step, the HMAC, the truncation and the code. RFC 6238 lists 94287082 for this moment at 8 digits; the last 6 are the code.
TOTP generator: three made-up accounts' current six-digit codes, each with its countdown ring and next codeTOTP generator: three made-up accounts' current six-digit codes, each with its countdown ring and next codeOne secret or manyA Base32 secret, an otpauth:// link, or one per line. Nothing you paste leaves the browser.The current codeComputed with Web Crypto from the secret and the 30-second step, as RFC 6238 describes it.Time left and the next codeThe ring counts down the step; the next code is ready when a login is slow or the clock is near the edge.What the key holdsSettings that aren't the defaults, and a secret shorter than the 128 bits RFC 4226 asks for.CopyCopies the code without its space. In the last five seconds, Copy next appears too.
Three made-up accounts in one box, one per line: each row has its current code, the seconds left and the next code. Select a number to see what each part shows.

How do I generate a key for Google Authenticator?

Make 20 random bytes, write them in Base32, and put them in an otpauth:// link with your service's name and the user's account; show that link as a QR code and the app adds the account.

Create a secret above does all of it in your browser: the secret comes from the browser's crypto.getRandomValues, and the link and QR code are built on the page. Keep the defaults (SHA-1, 6 digits, 30 s): they are what every authenticator app reads.

On a server, store the secret encrypted, check the first code the user types before turning 2FA on, allow a step of drift (RFC 6238 §5.2 and §6), and refuse a code that has already worked once. Give the user recovery codes in case the phone is lost.

  1. 20 random bytes
  2. Base32
  3. otpauth:// link
  4. QR code
  5. Scanned by the app
QR code for the made-up Example account

otpauth://totp/Example:alice@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example

  • Scheme
  • Type
  • Label: issuer and account
  • Secret (Base32)
  • Issuer
A made-up account's link, taken apart: the label, the secret and the issuer. Only the secret makes the codes.

Why is my 2FA code not working?

Most often the clock: a phone or computer whose time is off by more than a step makes codes the server no longer accepts. Turn on automatic date and time, then try again.

RFC 6238 recommends allowing at most one step for network delay and lets each server choose how much clock drift to forgive; many accept one step either side of their own. A clock off by more than about 30 seconds then starts to fail. This page checks your device's clock against our server's when it opens.

Then check the secret: a mistyped character (0 for O, 1 for I or L, 8 for B) makes a different, wrong code without any error. A setting the service didn't tell you about (SHA-256, 8 digits, 60 seconds) does the same. Last, RFC 6238 says a code that worked must not be accepted a second time: to sign in again, wait for the next one.

Google Authenticator has had no time-correction setting since version 7.0: Google's help says it uses the time setting of the phone's operating system, so fixing the phone's clock fixes its codes.

−60 sRefused
−30 sAccepted
Server's stepAccepted
+30 sAccepted
+60 sRefused
  1. The clock
  2. The secret, character by character
  3. Algorithm, digits and period
  4. A code already used
A common setting: the server's step and one either side are accepted (RFC 6238 §6 leaves the limit to each server). A device clock a minute off makes codes two steps away: refused.

The otpauth:// format

An otpauth:// link (Google's Key Uri Format) holds everything an authenticator app needs: the type, a label, the Base32 secret, the issuer and the settings.

The label is the issuer and the account joined by a colon; the issuer should also be a parameter, because some apps read only that. Parameters left out take their defaults. The secret is Base32 without padding.

PartNeededWhat it says
totp or hotpRequiredTime-based or counter-based codes.
labelRequiredIssuer:account, shown in the app. The issuer prefix is recommended.
secretRequiredThe shared secret in Base32. Google's page: padding “should be omitted”.
issuerStrongly recommendedThe service's name. Google's page: older Google Authenticator versions ignored it.
algorithmOptionalSHA1 (default), SHA256 or SHA512. Google's page: ignored by Google Authenticator.
digitsOptional6 (default) or 8. Google's page: ignored on Android and BlackBerry.
periodOptionalSeconds per step, 30 by default (TOTP only). Google's page: ignored by Google Authenticator.
counterHOTP onlyThe starting counter, required for hotp links.
The notes are quoted from Google's Key Uri Format page, read on 29 October 2026. Other authenticator apps document their own support.

TOTP vs HOTP

HOTP (RFC 4226) moves to the next code when you ask for one; TOTP (RFC 6238) moves every 30 seconds by itself. The computation is the same: only the counter differs.

An HOTP code stays good until it is used, which is convenient and is also its weakness: a code someone sees can be used later. TOTP codes expire on their own. When an HOTP token is pressed without logging in, the server falls behind: RFC 4226 recommends a look-ahead window, in which the server tries the next few counters and catches up when one matches.

TOTP: the clock moves the counter

  1. 0 sCounter 0755 224
  2. 30 sCounter 1287 082
  3. 60 sCounter 2359 152
  4. 90 sCounter 3969 429

HOTP: each press moves the counter

  1. Press 1Counter 0755 224
  2. Press 2Counter 1287 082
  3. Press 3Counter 2359 152
  4. Press 4Counter 3969 429
The same secret and the same counter value give the same code in both: RFC 4226's test key at counter 1 is 287 082 either way.

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

Only into one that never sends it anywhere. This page computes the codes in your browser with Web Crypto: the secret never leaves the page, never goes into a URL and isn't stored.

A 2FA secret is as sensitive as a password: anyone who has it can make your codes. On this page it lives only in the text box and the page's memory: no request carries it, it isn't written to the address bar, history or browser storage, and it's gone when you close the tab. Our automated tests type a secret and fail if the page makes any request after it.

For everyday logins, keep secrets in an authenticator app. This page is for checking codes, testing a 2FA setup, or reading a key you already hold.

Your browser

  1. Your secret
  2. Decoded from Base32
  3. HMAC in Web Crypto
  4. Your code

Our server

Nothing is sent

0 requests carry the secret

TOTP Generator FAQ

How do I get a 2FA code from a secret key?

Paste the secret (the Base32 text the service showed under its QR code, such as JBSWY3DPEHPK3PXP) into the box above. The current code appears with the seconds it has left, and the next code beside it. Spaces and lower case are fine. If the service gave you a QR code instead, use Read a QR image with a screenshot of it.

What is an otpauth:// link?

It is how a service hands a 2FA key to an authenticator app, usually inside a QR code: otpauth://totp/Example:alice@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example. It holds the type (totp or hotp), a label, the Base32 secret, the issuer and any non-default settings. Paste one above and the page reads all of them.

Why does my authenticator show a different code?

Check three things. The clock: the page checks your device's against our server's, and a clock off by 30 seconds or more gives other codes. The secret: one wrong character gives a different code without any error. The settings: a service using SHA-256, 8 digits or 60 seconds gives other codes if the app assumes the defaults. Near the end of a period, also compare the next code.

Can I use SHA-256 or 8 digits?

Yes: RFC 6238 allows HMAC-SHA-256 and HMAC-SHA-512, and codes of 6 to 8 digits. Open Settings above, or use an otpauth:// link with algorithm=SHA256 and digits=8. Not every app follows them: Google's Key Uri Format page says Google Authenticator ignores the algorithm, so use SHA-1 and 6 digits when people may use it.

Is my secret sent anywhere?

No. The codes are computed in your browser with Web Crypto: the secret never leaves the page, never goes into a URL and isn't stored in the browser. The only request the page makes on its own is the clock check when it opens, which carries nothing of yours. Our tests fail if the page makes any request after a secret is typed.

What is a TOTP secret?

A random key shared by you and the service when you turn on 2FA, usually 20 bytes written as 32 Base32 characters (16 characters is 10 bytes). Both sides keep it and compute the same code from it and the time. RFC 4226 asks for at least 128 bits and recommends 160. Treat it like a password: anyone with it can make your codes.

How do I move 2FA to a new phone?

In Google Authenticator, Google's help says to use Menu › Transfer codes › Export codes on the old phone and Import codes on the new one, scanning the QR codes it shows, or to sign in to your Google Account in the app to sync the codes. Microsoft Authenticator backs them up to iCloud on an iPhone or to a personal Microsoft account on Android, and restores only to the same kind of phone. Keep each service's recovery codes too.

Is TOTP the same as an SMS code?

No. An SMS code is made by the service and sent to your phone number each time, so it depends on the phone network and on your number staying yours: NIST lists SIM changes and number porting among its risks and restricts its use. A TOTP code is made on your own device from the shared secret and the clock, and nothing is sent.

Missing something?Suggest a feature or a new tool