TOTP Generator: Make and Check Codes

Compute the current RFC 6238 code from a Base32 secret, see how many seconds it has left, and read the previous and next codes. Check a code against a clock-skew window, or derive an RFC 4226 HOTP code from a counter you type.

The secret is visible in this tab. It is not saved, it is not put in the address bar, and it is not sent anywhere. Scripts and extensions that can read this page can read it. Supporting browsers disguise the letters until you choose Show secret. Use a test secret, or one you can rotate, and close the tab when you finish.

Secret

Length and a short-key warning appear after a valid secret.

Settings

Codes

Enter a Base32 secret to compute a code.

Check a code

Compare a code you already have with this secret, clock, and settings. The search starts at the current step and moves outward. It does not contact a service.

Enter a code and choose Check code. The search stays in this tab.

HOTP from a counter

RFC 4226. The counter is the event count you type. It does not advance by itself and it is not saved.

Not computed yet.

otpauth URI

The URI is text you can copy into an app that accepts it. This page does not draw a QR code and does not call a QR service. Issuer and account change the URI only. They do not change the code.

How it works

A TOTP code is an HOTP code whose counter is the number of whole periods since T0. With the usual settings, T0 is 0 and the period is 30 seconds, so the counter is the Unix time divided by 30. That counter is eight big-endian bytes. This page signs those bytes with HMAC-SHA-1, HMAC-SHA-256, or HMAC-SHA-512 through crypto.subtle, then applies RFC 4226 dynamic truncation: the low four bits of the last digest byte pick an offset, four bytes there become a 31-bit integer, and the code is that integer modulo 10 to the digit count, padded with zeros.

The previous and next codes are the neighboring counters. Checking a code starts at the current step and moves outward up to the window you set. Offset -1 means the code belongs to the previous period. A match only means this page can reproduce the code. It does not ask a remote service what it will accept.

Base32 follows RFC 4648. Case, spaces, and hyphens are ignored, and trailing equals signs are optional. The digits 0, 1, 8, and 9 are not in the alphabet. A string that looks like hexadecimal is rejected rather than decoded as Base32. RFC 6238 Appendix B prints the 20-byte ASCII seed 12345678901234567890. The SHA-256 and SHA-512 rows match only when that pattern is extended to 32 and 64 bytes. The sample menu loads those seeds and pauses the clock. At Unix time 59 with 8 digits, SHA-1 is 94287082, and the previous code is 84755224. The last six digits of that previous code, 755224, are the counter-0 value in RFC 4226.

The otpauth text follows the Google Authenticator Key URI format. T0 is not part of it. Some authenticator apps ignore algorithm, period, or a digit count other than 6, so compare one code after you import a non-default URI. Standards: RFC 6238, RFC 4226, and the Key URI format.

  • The clock is this device's clock. There is no network time check.
  • The secret is visible in this tab. This page does not save it, does not put it in the address bar, and does not send it anywhere.
  • No QR code is drawn, and no QR service is called.
  • Use this for a test secret or to check an implementation, not as the home for everyday accounts.
  • A wider window accepts more codes. RFC 6238 suggests at most one step for network delay.
  • Keys shorter than 128 bits still produce a code, and the page marks them as short. RFC 4226 requires at least 128 bits.
  • Seven-digit codes are computed here. The Key URI format only lists 6 and 8.
  • HOTP stays on the counter you type. This page does not store or advance it.