RFC 6238: The Standard Behind Every Authenticator App
Every six-digit code you've ever typed from an authenticator app follows the same published specification: RFC 6238, "TOTP: Time-Based One-Time Password Algorithm," defined by the Internet Engineering Task Force. It's an open standard, not a proprietary trick owned by any one company — which is exactly why a browser-based tool like AuthBro can generate codes that are indistinguishable from a dedicated mobile app's output. Both are implementing the same math from the same document.
TOTP itself is a small extension of an earlier standard, HOTP (HMAC-based One-Time Password, RFC 4226), which used an incrementing counter instead of time. TOTP swaps that counter for the current timestamp, so both sides of the exchange — your account and your authenticator — always agree on "now" without needing to talk to each other.
The Core Time-Step Formula
The first step in generating a TOTP code is turning the current time into a counter value, referred to as T:
T = floor((Current Unix Time - T0) / X)
Here, T0 is the Unix epoch, effectively 0, and X is the time-step size — almost universally 30 seconds. This means T only changes once every 30 seconds, which is exactly why a code stays valid for that window and then rotates. If X were 1 second, codes would expire before most people could finish typing them; if it were 5 minutes, a stolen code would stay dangerous for far too long. Thirty seconds is a deliberate balance.
HMAC-SHA1: Turning a Secret and a Time Into a Number
Once T is known, it's combined with your account's secret key using an HMAC-SHA1 function — a cryptographic hashing operation that's effectively impossible to reverse. Feed it the same secret key and the same time counter, and it always produces the same 160-bit hash. Change either input even slightly, and the output is completely different and unpredictable, with no partial correlation to the original.
This property is what makes TOTP secure: someone watching a single valid code learn essentially nothing about the secret key that produced it, and nothing about what the next code will be.
Dynamic Truncation: From a Long Hash to a Short Code
A raw HMAC-SHA1 hash is far too long to type at a login screen, so RFC 6238 defines a process called dynamic truncation to shrink it down:
- The last 4 bits of the hash are used to pick an offset into the hash itself.
- Four bytes starting at that offset are extracted and interpreted as a 31-bit integer (the top bit is discarded to avoid sign-related issues).
- That number is taken modulo 106, leaving a value between 0 and 999,999.
- The result is padded with leading zeros to always display as six digits.
That six-digit number is the code you type. It looks arbitrary, but it's fully deterministic — anyone (or anything) with the same secret key and the same time will always compute the exact same result.
Why This Design Needs No Network Connection
Because every input to the algorithm — the secret key and the current time — is already known locally, TOTP generation never has to phone home. Your account and your authenticator each run the identical calculation independently and simply expect to land on the same answer. That's a meaningful security property in its own right: there's no code traveling across the internet at generation time for anyone to intercept, log, or replay. You can watch this happen in practice — AuthBro runs this exact RFC 6238 computation entirely inside your browser tab every 30 seconds. Open your browser's developer tools while it's running and you won't see a single network request carrying your secret key anywhere.
The strength of TOTP isn't that the math is exotic — HMAC-SHA1 and modular arithmetic are well-understood, decades-old tools. The strength is that the entire calculation happens locally, with nothing secret ever transmitted.
What This Means for Everyday Use
Understanding the mechanics explains a few things you may have noticed as a user:
- Codes always expire in about 30 seconds — that's the time-step window, not an arbitrary UI choice.
- Codes work even offline — there's no server round-trip involved in generating one.
- A wrong device clock breaks logins — since T is derived from real time, a clock that has drifted enough will produce a code the server doesn't recognize (more on how this is handled in the next guide).
- The same secret key always produces the same sequence of codes — which is exactly why a QR code (encoding that key) is all a new device needs to start generating identical codes to your original one.
