The Maths Behind Everyday Life
The story, the formula and a worked example — see exactly where this maths shows up in the world around you.
Why your authenticator code changes every 30 seconds
A shared secret plus the current time generates a fresh 6-digit code — one of a million.
Authenticator apps show a 6-digit code that refreshes every 30 seconds. Both your app and the server mix a shared secret with the current time, so they compute the same code without ever sending it.
Hash the secret with the time
A time-based one-time password hashes the secret together with the current 30-second time step, then truncates to 6 digits — one of a million values.
TOTP code
Why it expires
The time step changes.
A short-lived secret
- 1
Code space
- 2
30-second window
After 30 seconds the time step changes and the old code is useless — even if intercepted.
A million possible codes, each valid for only 30 seconds, foils reuse.
The formula behind it
TOTP
The takeaway
TOTP mixes a shared secret with the clock to make a 6-digit code that both sides can compute but which expires in seconds.