How does two-factor authentication work?
A stolen password alone is no longer enough: the thief would also need your phone, or to trick you into typing the current code into a fake site, so never share a code with anyone who calls or messages you.
Overview
Short answer
Try real authenticator codes: your phone and the website compute the same six digits from a shared secret and the time.
Passwords get stolen all the time, through data breaches, phishing and reuse across sites. Two-factor authentication (2FA) adds a second proof that only you should have, so a stolen password alone isn't enough to get in.
Play with the figure, then press Next (or the → key) to go step by step.
Three kinds of proof
Security people sort proofs into something you know (a password or PIN), something you have (a phone or security key) and something you are (a fingerprint or face). 2FA combines two different kinds, so an attacker has to steal two very different things.
How authenticator codes work
When you set up an authenticator app, the website shows a QR code containing a random secret. Your phone saves it, and so does the site. Every 30 seconds, both sides feed the secret and the current time into the same cryptographic hash function and take six digits from the result. Because they share the secret and the clock, they get the same code, without ever talking to each other. A code expires within about a minute, so a stolen one is soon useless.
SMS codes, push prompts and security keys
SMS codes are better than nothing, but attackers can intercept them or take over your number with a SIM swap. Push prompts are convenient but can be abused by flooding you with requests until you tap Approve. The strongest are security keys and passkeys: they use public-key cryptography tied to the real website's address, so a fake site can't use them even if you're fooled.
The weak point: you
The most common way past 2FA is persuading you to hand over the code: a fake login page that relays it in real time, or a caller claiming to be your bank. No genuine company will ever ask you to read out a code. Keep the backup codes from setup somewhere safe in case you lose your phone.
Common myths
- "Authenticator apps need the internet." They only need the secret and the time, so they work in airplane mode.
- "2FA makes an account unhackable." It blocks most attacks, but phishing and SIM swaps can still beat weaker methods.
- "It's only for banks." Your email is the key to resetting every other account, so it needs 2FA most.
Questions people ask
What happens if I lose my phone?
Use the backup codes you saved when setting up 2FA, or another method you registered. Some authenticator apps can also sync secrets to a new phone through a backup.
Is SMS two-factor safe?
It is much safer than a password alone, but weaker than an authenticator app or security key because texts can be intercepted or a number hijacked by SIM swapping.
Why does my code not work?
The most common cause is the phone’s clock being wrong. Set the time to update automatically. Also check you are using the code for the right account.
What is a passkey?
A passwordless login that stores a private key on your device, unlocked with your fingerprint, face or PIN. It combines something you have and something you are, and resists phishing.
Is 2FA the same as two-step verification?
They are used almost interchangeably. Strictly, 2FA requires two different kinds of factor, while two-step can mean any two steps.
Test yourself
Pick an answer for each question. Every answer comes with an explanation.
0/4 answered01What do your phone and the website share to make the same code?
02Why can’t a thief reuse a code they saw yesterday?
03Which 2FA method best resists phishing?
04Which pair is true two-factor?
Sources & more
Sources
- RFC 6238: TOTP: Time-Based One-Time Password Algorithm(opens in a new tab)
- Multi-factor authentication (Wikipedia)(opens in a new tab)
- More than a password (CISA)(opens in a new tab)
- Passkeys (FIDO Alliance)(opens in a new tab)
Last updated 2026-11-26
Keep exploring
- Money & SecurityExplore it
How does tap-to-pay work?
- Money & SecurityExplore it
How does an ATM work?
- Money & SecurityExplore it
How does a bank card chip work?
- Money & SecurityExplore it
How does a security camera work?
- Money & SecurityExplore it
How do online card payments work?
- Money & SecurityExplore it
How do metal detectors and airport scanners work?