Short answer: Both generate one-time codes from the same secret key and the same cryptographic function. The difference is what changes between codes. TOTP uses the current time, so codes expire every 30 seconds. HOTP uses a counter that increases each time you request a code, so a code stays valid until it is used. Almost every website you use is TOTP; HOTP survives mainly in hardware tokens and offline devices.

The one idea both share

When you enable 2FA, the service and your app agree on a shared secret — the string encoded in that setup QR code. From then on, both sides compute codes independently using HMAC, a standard keyed hash. Neither transmits anything; they simply arrive at the same six digits because they started from the same secret.

The only question is what gets hashed alongside the secret. That single choice separates the two standards:

TOTP is literally defined as HOTP with the counter replaced by a time step. It is an extension, not a rival. Our explainer on how TOTP codes work goes deeper on the time-based half.

How TOTP behaves

Your phone takes the current Unix time, divides by 30, and hashes that number with your secret. The server does the same. Same inputs, same output — no communication required, which is why authenticator apps work in aeroplane mode.

Consequences:

How HOTP behaves

Your device holds a counter starting at zero. Each time you generate a code, it increments. The server holds its own counter and increments when it accepts a code.

Consequences:

Side by side

Which is more secure?

TOTP, for one practical reason: time limits exposure. A code glimpsed over your shoulder, sitting on a lock screen, or captured in a log is useless within half a minute. An HOTP code stays live until someone uses it, and an attacker who sees it may well get there first.

HOTP’s advantage is operational, not cryptographic. It works on devices with no clock and no battery to maintain one, and it works in environments where synchronising time is impractical. That is a real requirement in some settings — just not on your phone.

Both, however, share the same ceiling: a code you type can be typed into the wrong place. Neither resists a real-time phishing page that relays your entry to the genuine site. That gap is only closed by phishing-resistant methods — security keys and passkeys. The full picture is in can 2FA be hacked?

Where you actually meet HOTP

Most authenticator apps support HOTP if you need it. In Aegis, 2FAS, Authy or Google Authenticator you can pick the type when adding an account manually — see entering a setup key manually. If a service does not specify, it is TOTP.

Frequently asked questions

Which one does Google Authenticator use?

TOTP by default, and every mainstream website uses TOTP. Google Authenticator also supports HOTP through manual entry, where you choose “counter-based”.

Why does my authenticator ask for time-based or counter-based?

Because both standards exist and the app cannot tell which the service expects when you type a key by hand. Choose time-based unless the service explicitly says otherwise — that is right in almost every case.

My HOTP token stopped working. Why?

The counters have drifted apart, usually because the button was pressed repeatedly without the codes being used. Most systems offer a resynchronisation step where you enter two consecutive codes. Otherwise the administrator resets it.

Can the same secret be used for both?

Technically yes — the secret is just a key. But the service decides which algorithm it validates against, so you must match its choice. Using the wrong mode produces codes that never verify.

Is a 30-second window too short?

Servers typically accept the adjacent windows as well, giving around 90 seconds in total. If codes still fail, your clock is wrong rather than your timing. Turn on automatic network time.

Is there anything better than both?

Yes. FIDO2 credentials — security keys and passkeys — use challenge-response cryptography bound to the site’s domain, so there is no shared secret and no code to steal or mistype. Where offered, they are the better choice; TOTP remains the strongest option almost everywhere else.

The bottom line

TOTP is HOTP with a clock instead of a counter, and that one substitution is why it took over: codes that expire are safer than codes that wait. Unless you are holding a hardware token from your bank, everything you use is TOTP — so keep your phone’s clock synced and treat the setup secret like the password it effectively is.

Want to see the mechanism in action? Our browser-based 2FA code generator computes TOTP codes locally, and we explain what to watch for in is an online 2FA code generator safe?

2 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *