$ ./guess_the_languageCybersecurity
Cybersecurity · medium · #283

How does an authenticator-app TOTP code stay valid for only about 30 seconds?

code = HOTP(secret, floor(unix_time / 30))
  1. It combines a shared secret with the time window
  2. The server pushes a new code to the app each cycle
  3. A counter kept only on the server is incremented
  4. The phone fetches fresh codes from a cloud service
Both sides hash the same shared secret with the current time step, so the code rotates each window with no network traffic.
Play Cybersecurity ▸