HMAC-based one-time password (HOTP) is an algorithm for generating short codes that can each be used once to prove identity. It was published as RFC 4226 in 2005. The user's device and the server share a secret key and a counter. To make a code, the device computes an HMAC (a keyed hash) of the counter with the secret, then truncates the result to a six- to eight-digit number. Both sides then advance the counter.
HOTP is the basis of the time-based one-time password (TOTP), which replaces the counter with the current time so codes expire after a short interval; TOTP is the version found in most authenticator apps. HOTP codes stay valid until used, which suits hardware tokens but widens the window for misuse. Both are forms of one-time password (OTP) used for two-factor authentication (2FA) at banks and crypto exchanges, and are generally considered stronger than text-message codes, which are exposed to SIM swapping.
Ref 1300000312