The QR code a site shows when you turn on an authenticator app is a picture of one value: the TOTP secret key. Your phone stores it, the site stores it, and neither ever sends it again. Every code you type afterwards is computed from that key and the clock, which is why a code works without your phone being online.

What a TOTP secret key looks like

It is a string of capital letters and the digits 2 to 7, such as JBSWY3DPEHPK3PXP. That alphabet is base32: no 0, 1, 8 or 9, and no lowercase. Sites often print it in groups of four to make that easier, and the spaces mean nothing.

Under the letters is a run of random bytes. Each base32 character carries five bits, so the 16-character example above decodes to ten bytes, 80 bits. RFC 4226, the standard TOTP is built on, says the shared secret "MUST be at least 128 bits" and recommends 160 (RFC 4226, section 4, read 2 November 2026), which is 32 base32 characters. Google's own example is half that.

What is inside the QR code

The QR code holds a link in the otpauth:// format Google Authenticator defined. Its own example is otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example (Key Uri Format, read 2 November 2026). Only secret is required. issuer and the label say which site and account the key is for. Three optional settings change the code itself:

ParameterValuesDefault
algorithmSHA1, SHA256, SHA512SHA1
digits6 or 86
periodseconds per code30

The same page notes that Google Authenticator ignores algorithm and period, and ignores digits on Android.

Each profile keeps its own passwords and its own 2FA codesIn Mosaic: Logins and 2FA codes. A password vault and TOTP codes for each profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

How it works: Logins and 2FA codes

How the key turns into a six-digit code

RFC 6238 defines the code as HOTP with time in place of a counter (RFC 6238, read 2 November 2026). Spelled out:

  1. Take the current Unix time and divide it by 30, dropping the remainder. Every device in the world gets the same number for the same 30 seconds.
  2. Compute HMAC-SHA-1 of that number, with the secret key as the HMAC key.
  3. Use the last four bits of the result to pick four bytes out of it, and read them as a number.
  4. Keep the last six digits of that number.

The site does the same arithmetic when you sign in. The RFC recommends it accept at most one step of delay, so a code read in its last seconds may still pass and a code from two minutes ago will not. When codes fail while the key is right, check the device clock first.

Why the secret key matters more than any code

A code is good for 30 seconds. The key is good until somebody turns two-factor off. Whoever holds it makes your codes, for ever, from any device, and the site cannot tell their codes from yours. So treat a TOTP secret like a password:

  • Don't send it over chat or email, and don't leave a screenshot of the QR code in a photo library.
  • Keep one backup copy of it somewhere you control, beside the site's recovery codes.
  • If you think it leaked, turn two-factor off and on again. The site issues a new key and the old one stops working.

Keeping a backup is also why you want the text form as well as the picture. A key written down at setup moves to a new phone or a password manager in a minute. Without one, a lost phone means recovery codes or the site's account recovery, one account at a time. How to manage 2FA codes for multiple accounts covers labels, backups and recovery codes for a long list.

How Mosaic stores a TOTP secret key

Mosaic keeps a login vault in every profile, and each login can carry its secret (logins and 2FA codes). The Two-factor secret field takes the key in any of its three usual shapes: grouped with spaces, lowercase, or the whole otpauth:// link copied from behind the QR code.

We check the key when it is saved, not when a code is first asked for. It must be valid base32, and it must decode to at least 8 bytes, because a paste that stopped halfway decodes cleanly and then makes six wrong digits with no error. The check moved there after 29 September 2026, when the companion inside a profile's browser accepted not a key!! and answered "Saved to this profile."

Mosaic makes codes with the defaults: six digits, 30 seconds, SHA-1. It reads only secret from an otpauth:// link, so a site that issues eight-digit or SHA-256 codes needs an app that reads those parameters. The secret is sealed on disk with the rest of the profile's library, and our server never receives it (what our server does receive). The companion can copy the setup key or the otpauth:// link back out, so a key you keep in Mosaic is never stuck there. The vault is on every plan; pricing has the rest.