How do authenticator apps work?
An authenticator app works by combining a secret key, saved on your phone when you set up 2FA, with the current time, and turning that into a 6-digit code that changes every 30 seconds. The website holds the same secret and does the same calculation, so it can check your code without anything being sent to your phone.
That is the whole trick. There is no connection between the app and the website while you log in. Both sides just do the same maths and compare results.
If you are new to the idea of a second sign-in step, start with what 2FA is. This article covers what happens inside the app.
What is TOTP, the standard behind authenticator codes?
TOTP, short for Time-based One-Time Password, is an open standard (RFC 6238) that generates a short code from a shared secret and the clock. It builds on HOTP (RFC 4226), which does the same thing from a counter instead of the time.
Google Authenticator, Microsoft Authenticator, Authy, 1Password and most password managers all implement TOTP. That is why a code from one app can be moved to another: the standard is the same, only the place the secret lives changes.
A TOTP setup has just three ingredients:
- A shared secret, a random string of letters and numbers, usually shown as a QR code.
- The current time, counted in 30-second steps.
- A hash function that mixes the two into a number.
What happens when you scan the QR code?
Scanning the QR code copies the shared secret from the website into your app, once, and that is the only moment the two sides exchange anything.
The QR code is just a link in the otpauth:// format. It contains the secret (encoded in base32), the account name, the issuer, and sometimes settings such as the number of digits and the period. Your app stores it and starts generating codes immediately.
Two practical consequences follow. First, anyone who sees that QR code or the text key shown next to it can generate your codes forever, so treat it like a password. Second, the QR code is usually shown only once, so if you do not save the secret somewhere safe, losing the phone means losing the second factor.
How is the 6-digit code calculated?
The code is calculated by hashing the secret together with the number of 30-second steps since 1 January 1970 (UTC), then cutting the result down to 6 digits.
- Take the current Unix time and divide it by 30, ignoring the remainder. This whole number is the time step.
- Run the secret and the time step through HMAC (usually HMAC-SHA1) to get a long hash.
- Use part of the hash to pick four bytes, a step the standard calls dynamic truncation.
- Turn those bytes into a number and keep the last 6 digits.
Because the time step only changes every 30 seconds, you see the same code for that long. When the step ticks over, the same secret produces a completely different code, and nothing about the old code helps an attacker guess the next one.
Why do authenticator apps work offline?
Authenticator apps work offline because the calculation needs only the secret already stored on your device and the device clock, not an internet connection.
When you type the code, the website runs the same calculation on its own copy of the secret. If the two results match, you are in. This is why the app keeps working in airplane mode or abroad without data, and why it is more reliable than a text message code that depends on mobile coverage.
The one thing that must be right is the clock. Most servers accept the code from the previous and next 30-second window as well, to forgive small differences, but a clock that is minutes off will be rejected. If codes suddenly stop working, turn on automatic time on the device or use the time-correction option in the app.
Is an authenticator app safer than SMS codes?
An authenticator app is generally safer than SMS codes because there is nothing to intercept in transit and nothing a phone-number swap can redirect. Guidance such as NIST SP 800-63B treats SMS as a weaker option than a code generated on the device.
It is not perfect. A fake login page can still trick you into typing a valid code, and a TOTP code does not protect you if someone has stolen the secret. For the strongest protection against phishing, passkeys and hardware security keys are better; see what a passkey is.
| Method | Works offline | Main weakness |
|---|---|---|
| SMS code | No, needs mobile signal | SIM swaps and message interception |
| Authenticator app (TOTP) | Yes | Secret lost with the phone, phishing of the typed code |
| Passkey or security key | Yes | Needs device support on both sides |
Where should you store the authenticator secret?
Store the secret in a place you can recover if your phone is lost, ideally an encrypted password manager or a second device you set up at the same time.
Most people keep it only in a phone app, which is fine until the phone breaks. Before you rely on any setup, run through this checklist:
- When you enable 2FA, save the text key shown beside the QR code, or scan the QR on two devices.
- Save the backup or recovery codes the website gives you, and store them separately from the phone.
- Check whether your app has encrypted backup or sync, and turn it on if it does.
- Know how to move to a new phone before you wipe the old one. The steps are in how to move an authenticator app to a new phone.
How do you handle authenticator codes for shared accounts?
Shared accounts such as a company social media login or an ad account need the 2FA secret stored where the whole team can use it, not on one person's phone.
If the secret lives on one employee's phone, that person becomes a single point of failure. When they are on holiday, change role or leave, nobody else can sign in. Teams often fall back on forwarding codes in chat, which exposes a live code to everyone in that thread. The options are covered in how to share 2FA codes with a team.
BobWork Vault stores authenticator (TOTP) secrets next to the login and fills or copies the 6-digit code after the password. You can add the secret by scanning the QR code on the page, or by uploading or pasting a QR screenshot. It decodes the QR in your browser, and a Google Authenticator export QR can import several accounts at once.
You can also record who holds each login's 2FA, and a 2FA map shows which logins depend on one person. If a teammate with Login only access needs a code held by someone else, they can use "Ask for the code" and the holder sends it back, encrypted to that teammate only, and it expires after 10 minutes. Everything is encrypted in the browser, so the server stores ciphertext only. The wider setup is described in how to share passwords with teammates.
What should you remember when you set up 2FA for a team?
The key rule is that the secret is as sensitive as the password, so decide who may hold it before you scan it.
- Avoid screenshots of QR codes in chat or email. If you must use one, delete it afterwards.
- Keep a named owner for each account's 2FA and a second person who can recover it.
- Store backup codes with the login, not in a personal notes app.
- When someone leaves, treat any secret they could see as exposed, and reset 2FA on those accounts.
The last point matters most. Removing a person from the password manager does not change a secret they have already copied, which is why offboarding includes re-enrolling 2FA. The full list is in the employee offboarding password checklist.
To try this with your team, create a free BobWork Vault account and add your first authenticator secret to a shared login.
Try BobWork Vault — free for your whole team
BobWork Vault is a free, zero-knowledge password manager for teams, made by BobWork (BobOffice, LLC). Shared folders, login-only access, 2FA codes and guided offboarding, end-to-end encrypted. Add it to Chrome or create a free account.
Keep reading
- What Is a 2FA? Two-Factor Authentication Explained for Business Accounts
- Authenticator app on a new phone: how to move 2FA codes without getting locked out
- How to share 2FA codes with your team without waiting for one person's phone
- What Is a Passkey? How Passkeys Work and How They Differ From Passwords
More: free password manager · free team password manager · free company password manager · company password manager · password management software · how to share passwords with teammates · compare password managers
Questions
Do authenticator apps need internet?
No. The app calculates each code from the stored secret and your device clock, so it works in airplane mode. Only the first setup, and signing in to the website itself, need a connection.
Why does my authenticator code say invalid?
Most often the device clock is out of sync. Turn on automatic date and time, or use the time-correction option in your app, then try the next code. Also check you are using the code for the right account.
Can two devices show the same authenticator code?
Yes. If both devices hold the same secret, they generate identical codes at the same time. That is how you can set up a backup device or share a code through a password manager.
Can someone steal my authenticator codes without my phone?
Yes, if they get the secret, for example from the setup QR code or an unencrypted backup. The 6-digit code alone expires in 30 seconds, but the secret produces every future code.
Is it safe to store authenticator secrets in a password manager?
It is a reasonable choice if the manager is encrypted and protected with a strong master password, because it removes the lost-phone problem. The trade-off is that the password and second factor then sit in one place.
What happens if I lose my phone with my authenticator app?
You need the backup codes or a second device with the same secret to get back in. Without either, you must go through the website's account recovery, which can take days.