What a TOTP Secret Key Actually Is
Every TOTP setup starts with a secret key — a random string of bytes generated by the service you're enabling 2FA on. This key is the one piece of information that both your account and your authenticator will need forever afterward to calculate matching codes. It's generated once, shared once (via a QR code or manual entry), and from that point on it never needs to be transmitted again.
Because this key has to be shown to a human being at least once — for manual entry as a fallback to scanning — it needs to be represented as readable text rather than raw binary data. That's where Base32 comes in.
Why Base32 Encoding, Specifically
Base32 encodes binary data using a 32-character alphabet: the uppercase letters A–Z along with the digits 2–7. That's a deliberately narrow choice, and it solves a real, practical problem — most secret keys are set up once, by a person, sometimes by typing rather than scanning.
| Excluded Character | Why It's Left Out |
|---|---|
| 0 (zero) | Too easily confused with the letter O |
| 1 (one) | Too easily confused with the letter I or lowercase l |
| 8 (eight) / 9 (nine) | Not needed once 0/1 are excluded and the alphabet is defined as A–Z, 2–7 |
Compare that to Base64, which is used all over the web for things like email attachments and image data — it includes both uppercase and lowercase letters, digits, and symbols like + and /. That's far more compact, but it's much easier to mistype by hand, especially across fonts that render similar-looking characters ambiguously. For a value someone might need to type on a phone keyboard exactly right, Base32's slightly less dense but far less error-prone alphabet is the better trade.
What Happens When You Scan a 2FA QR Code
The QR code shown during 2FA setup isn't magic — it's just a compact way of encoding a standard URI, typically in this shape:
otpauth://totp/ServiceName:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=ServiceName
Scanning it simply reads that text out of the image. The secret parameter is your Base32-encoded key; everything else — the service name, your account label, and the issuer — is just metadata used to label the entry so you can recognize it later in a list of accounts. When AuthBro scans this same QR code, it's parsing this exact URI format and storing the secret encrypted, locally, in your browser's vault.
Handling Clock Drift Without Breaking Logins
Because a TOTP code is derived from the current time, the whole system depends on your device's clock and the server's clock roughly agreeing. In reality, device clocks drift by small amounts constantly — a few seconds here or there is completely normal and usually goes unnoticed for everyday timekeeping.
To account for this without weakening security meaningfully, standard TOTP validation doesn't check only the exact current time step — it also checks one step before and one step after. Since each step is 30 seconds, this effectively gives a small window of tolerance (commonly around ±30–60 seconds depending on implementation) before a code is rejected. AuthBro checks against these same adjacent time steps for this exact reason, so a device clock that's off by a handful of seconds still produces a code that logs you in, instead of failing every single time.
What Happens If Drift Gets Too Large
If a device's clock is off by minutes rather than seconds, codes will start failing consistently, because the drift now exceeds the small tolerance window built into validation. This is almost always a device clock problem, not an authenticator problem — the fix is checking that your device's automatic date-and-time setting is enabled, rather than a manually set (and often forgotten) clock.
Base32 exists to make a secret key survive a human typing it by hand without a mistake. The adjacent time-step check exists to make TOTP survive a clock that's a few seconds off. Neither weakens the underlying security — they just account for the reality that people and devices aren't perfectly precise.
A Note on Key Length and Randomness
The security of the entire scheme rests on that original secret key being genuinely random and long enough to resist brute-force guessing. RFC 6238 recommends at least 128 bits of entropy for the underlying key (160 bits when paired with HMAC-SHA1, matching the hash's output size), and the RFC 4648 specification is what actually defines the Base32 alphabet used to represent that key as text. In Base32 form, that typically shows up as a string around 32 characters long — noticeably longer than a typical password, and never meant to be memorized, only stored securely.
