piapia123
en

TOTP / HOTP Codes

Encoding

Everything runs locally in your browser — nothing is uploaded

Input
Drop a file here to load its contents
Output

⚠️ Please do not paste the secret for an account you actually use. Everything here really is computed locally with no requests, but the page came from the network — and a TOTP secret is the entire second factor, so anyone holding it can mint valid codes indefinitely. This tool is for checking that a secret a service gave you works, and for generating expected values when writing automated tests. The algorithm is two fixed steps: derive the counter (TOTP divides the current Unix time by the period; HOTP uses the integer you supply), then HMAC and dynamic truncation — take the low nibble of the last HMAC byte as an offset, read four bytes, mask to 31 bits, and reduce to six digits. The same secret at the same time therefore gives the same answer, and it should match your authenticator app digit for digit. ⚠️ This only computes what the code is right now; it does not verify anything — verification means submitting a candidate to a server, which is an online act. Also, how many neighbouring windows a server accepts is up to that server; the adjacent codes listed here are only the range it could tolerate.

Features

  • TOTP and HOTP per RFC 6238 / RFC 4226, passing every official test vector in both RFCs
  • ⚠️ The first line of the page warns against pasting a secret you use — a TOTP secret is the whole second factor
  • SHA-1, SHA-256 or SHA-512 (SHA-1 is what nearly every service defaults to)
  • Adjustable period and digit count (30 seconds and 6 digits by default, matching the usual apps)
  • Shows how many seconds are left in the window and the current counter value
  • Lists codes for neighbouring windows, so you can see how far a device clock has drifted
  • HOTP mode takes an explicit counter, handy for checking against the RFC vectors
  • Secrets may be lower case, space or hyphen separated, or padded; a secret containing 0, 1, 8 or 9 is reported as an error rather than guessed at

How to use

  1. ⚠️ Use a test account’s secret, not one you rely on
  2. Paste the Base32 secret
  3. Match the algorithm, period and digits (most services: SHA-1, 30 seconds, 6 digits)
  4. The six digits should match your authenticator app exactly

FAQ

Why does this differ from my authenticator app?
In order of likelihood: clock drift — TOTP depends entirely on both clocks agreeing, and a device off by more than 30 seconds lands in a neighbouring window, so turn on the neighbouring windows and see whether your app’s code appears there; mismatched parameters — algorithm (SHA-1 / 256 / 512), period (30 or 60 seconds) and digits (6 or 8) all change the result; a mistyped secret — secrets contain only A–Z and 2–7, and a handwritten one easily turns 0 into O or 1 into I, which this tool rejects outright rather than guess around.
What is the difference between TOTP and HOTP?
Only where the counter comes from. HOTP uses a counter both sides increment, one per use — but once client and server fall out of sync they never match again, and every press that fails to log in still burns a counter value. TOTP uses time as the counter (current time divided by the period), so as long as the clocks roughly agree no state has to be synchronised. The cost is a 30-second window and a hard dependency on accurate clocks.
Which is worse to leak — the secret or a code?
The secret. A code expires in 30 seconds and is useless without your username and password as well. The secret mints valid codes forever — whoever holds it can sign in at any time and nothing looks unusual on your side. So a leaked secret is the second factor failing entirely, while a leaked code affects only those 30 seconds.
Can this verify that a code is correct?
No, and it should not. Verification means submitting a candidate to a server, which is an online act this static site does not perform. What it answers is “what does this secret produce right now” — compare that against your own authenticator app, and if they agree, the secret and the parameters are both right.

Related tools