TOTP Code Generator

Two-Factor Authentication (TOTP) Code Generator

The secret is used only inside this page, on your device. It is never sent to any server, and nothing is saved. Only enter secrets for accounts that you own.

Spaces and lowercase letters are accepted. Trailing = padding is ignored.

Advanced: check the code at a fixed Unix time

------

Enter a secret to begin.

What a TOTP Code Is

A time-based one-time password is the short numeric code many services request after your password. It is defined in RFC 6238, which builds on the HMAC-based one-time password scheme in RFC 4226. The service and your app share a secret key once, during setup. From then on each side can compute the current code on its own, without contacting the other.

The code depends on three inputs: the shared secret, the current Unix time and a period, usually 30 seconds. The time is turned into a counter by dividing by the period and rounding down. The counter is what gets hashed, so a code stays the same for a whole period and changes at each boundary.

How the Calculation Works

The page runs the standard steps in your browser, using the Web Crypto API for the keyed hash. Nothing leaves the page.

1. Decode the secretThe Base32 text is turned into raw bytes using the RFC 4648 alphabet.
2. Build the counterUnix time divided by the period, rounded down, becomes an 8-byte big-endian value.
3. Compute the HMACHMAC with the chosen hash (SHA-1, SHA-256 or SHA-512) is calculated over the counter.
4. Truncate and reduceA four-byte slice selected by the last hash byte is reduced modulo 10 to the power of the chosen digit count.

RFC 6238 Test Vectors

RFC 6238 publishes test values so that independent implementations can be compared. The SHA-1 vectors use the ASCII secret 12345678901234567890, which is GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ in Base32. Each value is reproduced by entering the matching secret and algorithm, then setting the advanced fixed time to the Unix time shown.

Unix timeAlgorithmDigitsCode
59SHA-1894287082
59SHA-16287082
1111111109SHA-1807081804
59SHA-256846119246
59SHA-512890693936

Matching these values confirms the counter, HMAC and truncation steps. It does not confirm anything about a live account, which depends on the service's own clock and settings.

Frequently Asked Questions

Is my secret sent anywhere?

No. The secret is read, decoded and used only inside this page, through your browser's Web Crypto API. The page makes no network requests with the secret, and it does not save it to local storage or cookies. Reloading or clearing the page removes it from the screen.

Should I use this instead of an authenticator app?

This page is a calculator for checking codes, testing a service you are building, or learning how TOTP works. For everyday logins a dedicated authenticator app on a separate device is the better home for your codes, because two-factor protection depends on the second factor being kept apart from the password.

Why does the code change every 30 seconds?

The code is computed from a counter equal to the Unix time divided by the period, rounded down. The counter stays the same for the whole period and moves on at each boundary, so the code changes at the same moment for the server and for the device, provided both clocks agree.

What does the fixed Unix time option do?

It computes the code for a moment you choose instead of the current one. That is useful for matching the RFC 6238 test vectors or for looking into a clock offset. The countdown pauses while the option is in use, and the page shows the time it is using.