Home / Guides / Two-factor authentication explained: authenticator apps, SMS and passkeys
Two-factor authentication explained: authenticator apps, SMS and passkeys
A password alone is a single point of failure. If it leaks, is guessed or is stolen through a fake page, whoever has it can sign in as you. Two-factor authentication (2FA), also called multi-factor authentication, adds a second proof, so that a stolen password is not enough.
The three kinds of factor
Authentication combines things of different types:
- Something you know: a password or PIN.
- Something you have: a phone, a security key, an authenticator app.
- Something you are: a fingerprint or face scan.
True 2FA uses two different types. A password plus a security question is not 2FA, because both are things you know.
The common methods compared
| Method | How it works | Strengths | Weaknesses |
|---|---|---|---|
| SMS code | A code is sent by text | Easy, nothing to install | The phone number can be hijacked (SIM swapping), messages can be intercepted, codes can be phished |
| Authenticator app (TOTP) | An app shows a code that changes every 30 seconds | Works offline, no phone number involved | The code can still be typed into a fake page and relayed |
| Push approval | You tap “Approve” on your phone | Convenient | Attackers spam requests until someone approves (“prompt bombing”) |
| Security key (FIDO2) | A physical key confirms you are on the real site | Resistant to phishing | You have to buy and carry one |
| Passkey | A cryptographic key stored on your device, unlocked by fingerprint, face or PIN | Resistant to phishing, nothing to type | Support is still growing, and recovery needs planning |
Standards bodies such as NIST classify SMS codes as a “restricted” authenticator, which means it is allowed but not recommended for anything sensitive. A text code is still far better than no second factor at all.
How an authenticator app generates codes
Authenticator apps use TOTP, the Time-based One-Time Password algorithm (RFC 6238), which builds on HOTP (RFC 4226).
- Setup. The service creates a random secret and shows it as a QR code (or as text in Base32). Your app stores it. The service stores the same secret.
- Counting time. Both sides divide the current time into 30-second steps. The step number is the “counter”.
- Calculating. Each side computes an HMAC (by default HMAC-SHA1) of the counter using the secret.
- Shortening. A small part of the result is extracted and reduced to six digits.
- Checking. You type the six digits. The server calculates the same value and compares. Most servers also accept the previous and next step, to allow for clock drift.
The consequences:
- The code works offline, because nothing travels between the app and the server except what you type.
- Both devices need a correct clock. If codes are always rejected, check that your phone time is set automatically.
- Whoever has the secret has the codes. That is why the setup QR code should never be shared or stored in a screenshot.
- The code is only valid for a short time, but that is still enough for a live phishing page to use it immediately.
You can see this in practice with our 2FA code generator. It calculates the code from a Base32 secret following the standard settings. Use it for testing, and use a dedicated app for real accounts.
Phishing and one-time codes
Codes protect you from someone who only knows your password, for example from a breach. They do not protect you from a convincing fake login page that asks for the code and passes it on in real time.
Methods tied to the real site, such as security keys and passkeys, avoid this problem. They check the domain themselves, so on a fake page they simply refuse to respond. For important accounts, such as email, banking and your password manager, prefer them when offered.
Which one should you use?
- Passkey or security key if the service supports it.
- Authenticator app otherwise.
- SMS only when nothing else is offered.
- Turn it on first for your email account. Whoever controls your email can reset almost every other password.
Backup and recovery: the part people forget
The main risk of 2FA is locking yourself out.
- Save the recovery codes that the service gives you when you enable 2FA. Print them or store them in your password manager, not in the same place as your phone.
- Add a second method if the service allows it, such as a second key or a second device.
- Choose an app that supports backup or export if you change phones often, and test the transfer before you wipe the old one.
- Know the recovery procedure for your most important accounts before you need it.
Mistakes to avoid
- Sending a one-time code to anyone, including someone claiming to be from “support”. No real company asks for it.
- Approving a push request you did not trigger.
- Storing the setup secret or QR code in a note or a screenshot.
- Relying on the same device for the password manager and the authenticator, without a recovery plan.
- Thinking 2FA makes a weak password acceptable. Both matter. Use the Password Generator for a unique password per account, and check old ones with the Password Breach Checker.
For a broader view of password habits, read how to create a strong password.