# What is a TOTP secret key?

> A TOTP secret key is the shared random value behind a 2FA QR code. Your app and the site both hold it and turn it into the same six digits every 30 seconds.

Source: https://mosaicbrowser.com/guides/totp-secret-key

## What is a TOTP secret key?

A TOTP secret key is the random value a site and your authenticator app share when you turn on two-factor authentication, usually shown as base32 text under the QR code. Both sides combine it with the current time to compute the same six-digit code every 30 seconds.

![The key behind the QR code, beside a screenshot: mosaic security settings: everything on disk sealed with AES-256-GCM, and an optional app lock](https://mosaicbrowser.com/covers/totp-secret-key.webp)

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](https://datatracker.ietf.org/doc/html/rfc4226), 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](https://github.com/google/google-authenticator/wiki/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:

| Parameter | Values | Default |
| --- | --- | --- |
| `algorithm` | SHA1, SHA256, SHA512 | SHA1 |
| `digits` | 6 or 8 | 6 |
| `period` | seconds per code | 30 |

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

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Logins and 2FA codes](https://mosaicbrowser.com/features/logins-and-2fa)

## 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](https://datatracker.ietf.org/doc/html/rfc6238), 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](https://mosaicbrowser.com/guides/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](https://mosaicbrowser.com/features/logins-and-2fa)). 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](https://mosaicbrowser.com/features/local-first)). 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](https://mosaicbrowser.com/pricing) has the rest.

## Sources

1. [RFC 6238: TOTP, Time-Based One-Time Password Algorithm](https://datatracker.ietf.org/doc/html/rfc6238), read November 2, 2026
2. [RFC 4226: HOTP, an HMAC-Based One-Time Password Algorithm](https://datatracker.ietf.org/doc/html/rfc4226), read November 2, 2026
3. [Google Authenticator wiki: Key Uri Format](https://github.com/google/google-authenticator/wiki/Key-Uri-Format), read November 2, 2026

## Questions

### Is the TOTP secret key the same as a recovery code?

No. The secret key makes a new code every 30 seconds, for as long as two-factor stays on. A recovery code is a single-use password the site gives you for the day you have lost the key, and each one works once.

### Can I get the secret key back from an authenticator app?

Sometimes. Some apps export accounts as QR codes, which carry the key inside an otpauth link, and some show the key on request. If yours does neither, turn two-factor off and on again on the site, which issues a new key.

### Why does a site say my code is wrong when the key is right?

Usually the clock. The code is computed from the current time, and RFC 6238 recommends a site accept at most one 30-second step of delay. A phone or computer whose clock has drifted produces codes the site no longer accepts.

### Is it safe to keep TOTP secrets in a password manager?

It puts both factors in one place, which is a trade-off: convenient, and only as safe as that vault. Keep the vault behind its own strong password and keep the site's recovery codes somewhere else.

## Related

[How to manage 2FA codes for multiple accounts](https://mosaicbrowser.com/guides/manage-2fa-codes-for-multiple-accounts): Keep each account's 2FA secret next to its login, back the secrets up somewhere you control, and save recovery codes before you need them.

[2FA codes per browser profile, with a login vault each](https://mosaicbrowser.com/features/logins-and-2fa): Mosaic keeps 2FA codes per browser profile: each profile has its own login vault with TOTP codes, shown with a countdown and typed with real keystrokes.

[Local first: your profiles stay on your computer](https://mosaicbrowser.com/features/local-first): Mosaic has no cloud copy of your profiles. Profiles, cookies and proxies stay on your computer, encrypted on disk, with app lock, daily backups and a trash.











[How to test your app with multiple user accounts](https://mosaicbrowser.com/guides/test-your-app-with-multiple-user-accounts): Test your app with multiple user accounts: one seeded account per role, a separate browser session for each, and saved sign-in state so tests skip the login.

[Can you have multiple Tumblr accounts? Yes, and many blogs](https://mosaicbrowser.com/guides/can-you-have-multiple-tumblr-accounts): Can you have multiple Tumblr accounts? Yes: one email per account, and each account can add ten sideblogs a day. Mass registration and spam are banned.

[How many InMails do you get on LinkedIn? Credits by plan](https://mosaicbrowser.com/guides/how-many-inmails-do-you-get-on-linkedin): LinkedIn gives 5 InMail credits a month on Premium Career, 15 on Business, 30 on All-in-One, 50 on Sales Navigator. A reply within 90 days returns the credit.

## Run this guide on your own accounts

Every Mosaic profile is a fingerprint, a proxy IP and a cookie jar that agree with each other, kept on your computer. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
