Loading Techie Utils…

HOTP Generator

Create a counter-based HOTP secret, its codes and the QR code to enrol with. Free, and runs entirely in your browser — nothing is uploaded.

About TOTP / HOTP Generator

HOTP and TOTP are the same four lines of arithmetic. Take a shared secret, take a counter, HMAC one with the other, and pull six digits out of the result. HOTP's counter increases each time a code is used; TOTP's is the clock divided by a step, almost always thirty seconds. The QR code, the app, the six digits on your phone — all of it is packaging around that.

The tool is two decisions rather than one list. Create a secret sets one up — generate a new one by leaving the box empty, or paste one you already have to keep it while the parameters change around it. Check a code tests one somebody has given you. Each works in either scheme, because TOTP and HOTP differ only in what they count.

Enrolment is the other half. The otpauth:// URI is built from whatever is configured — the secret, the issuer, the account, the hash, the digit count, and the period or the counter — and drawn as the QR code an authenticator app actually scans, because a secret that has to be typed by hand is a secret that gets typed wrong. Both the URI and the drawing are produced in this tab, so the secret never leaves it to become an image somewhere else.

Which is why the other useful half of this tool is verification rather than generation. A rejected code is almost never a wrong code: it is a clock a minute out, or a secret pasted with the wrong alphabet, or six digits where the server wants eight. Checking a code here reports which window it matched and how far the clock has drifted, which is the thing no authenticator app will tell you and the thing that actually explains the failure.

Where it helps

  • Matches the RFC 4226 and RFC 6238 test vectors exactly, across SHA-1, SHA-256 and SHA-512.
  • Reads a whole otpauth:// URI and uses the parameters in it rather than assuming the defaults.
  • Verification reports the counter it matched at and the clock drift that implies — what a server would record — instead of a bare yes or no.
  • Checks HOTP codes as a real server does: looking ahead through the resynchronisation window and never behind it.
  • Draws the enrolment QR code for any configuration, so a secret can be scanned rather than typed.
  • The secret is only ever used in this tab — nothing is sent anywhere.

Limits

  • A tool that holds the shared secret and shows codes is a second factor that is no longer a second factor — use it for debugging, not as your authenticator.
  • It uses this machine's clock, so a drifting clock here produces codes that look wrong when they are not.
  • HOTP counters move on the server when a code is consumed; nothing here can know where a server's counter has got to.
  • Codes are not the hard part of two-factor security — enrolment and recovery are, and neither is covered here.

Frequently asked questions

My code is rejected. What is actually wrong?

Check the three things that differ invisibly: the number of digits, the period, and the hash. An authenticator app shows none of them. After that, check the clock — use Verify, which reports how far out it is.

Why do most services use SHA-1?

Because RFC 4226 specified it and every authenticator app assumes it. SHA-1's collision weaknesses do not affect HMAC, so this is one of the few remaining places it is not a problem.

How long should a secret be?

RFC 4226 requires at least 128 bits and recommends 160, which is the twenty-byte default here — thirty-two Base32 characters.

Why can an HOTP check look ahead but not behind?

Because a counter the server has already passed belongs to a code that has been used, and accepting it again would make that code replayable. Looking ahead absorbs unused button presses; looking behind would undo the whole point of a one-time password.

How many windows should a server accept?

One either side is usual: it absorbs about thirty seconds of clock drift. Every extra step widens the window an attacker has to replay a stolen code.

Related tools

  • HMAC Generator — Keyed message authentication codes
  • Base32 — Encode or decode Base32 in the RFC 4648, extended hex and Crockford alphabets
  • QR Code Generator — Create scannable QR codes as SVG
  • Password Generator — Strong random passwords with an entropy estimate
  • Hash Generator — SHA-2, SHA-3, BLAKE and legacy digests, in any encoding
  • MD5 Generator — MD5 digests, with a plain account of what they are still good for

More Security & Cryptography tools

  • Hash Generator — SHA-2, SHA-3, BLAKE and legacy digests, in any encoding
  • MD5 Generator — MD5 digests, with a plain account of what they are still good for
  • HMAC Generator — Keyed message authentication codes
  • Key Derivation — Stretch a passphrase into key material with PBKDF2, scrypt or Argon2id
  • Password Generator — Strong random passwords with an entropy estimate
  • Password Strength — Judge a password by what an attacker would actually try
  • JWK Generator — A JSON Web Key for a JOSE algorithm, with its key set and thumbprint id
  • Key Pair Generator — RSA and elliptic-curve key pairs, generated in this tab and never sent
  • TOTP / HOTP Generator — Two-factor codes, the QR code to enrol with, and why one did not match
  • Text Encryption — AES-256-GCM with a PBKDF2 passphrase
  • Bcrypt Generator — Hash a password with bcrypt, verify one against a hash, or read what a hash is made of