How two-factor authentication works and which type to use
Compare text message codes, authenticator apps and security keys for two-factor authentication, see how each one protects you, and choose the right method for each account.
Two-factor authentication adds a second proof of identity to your sign-in, so that a stolen password alone is not enough to get into an account. The second factor is usually a code you type, a tap on an approval prompt or a physical key that you plug in or hold near your device. Because attackers rarely have both your password and the second factor, enabling it blocks most automated and password-based attacks. It is one of the most effective protections most people can add.
The methods are not equal. Text message codes are the most common and the easiest to set up, but they are the weakest of the mainstream options. Authenticator apps and security keys offer stronger protection against phishing and SIM-based attacks. The right choice depends on how valuable the account is, how comfortable you are with setup and whether the service offers the stronger methods.
Why a second factor helps
A password can be leaked in a breach, guessed from a reused pattern or entered on a fake page through phishing. A second factor makes those problems much less damaging. Even if someone obtains your password, they cannot finish signing in without the code, prompt or key that only you can produce. Some methods also resist phishing, because security keys and passkeys are tied to the real site's address and will not sign in on a fake one.
Two-factor authentication is not a guarantee. A determined attacker can still trick you into approving a request you did not make, or try to take over your phone number. Use it as one layer among others, such as unique passwords and careful checking of messages. When you set it up, save the backup codes that many services provide, and store them somewhere secure.
Text message codes
A text message code sends a short numeric code to your phone each time you sign in. It requires no app and works on almost any phone, which is why services often offer it first. Its main weakness is that the message travels through the phone network, and an attacker who convinces your mobile carrier to move your number to a new SIM card, a technique called SIM swapping, can receive your codes. Attackers can also intercept codes through phishing pages that ask you to type the code in real time.
Text codes are still better than no second factor, and they may be the only option on some services. If you use them, keep your mobile account protected with a carrier account PIN or passcode, and ask your carrier about its procedures for changing a number or SIM. Recovery and carrier protections can differ by provider and by state, so confirm the options with your carrier.
Authenticator apps
An authenticator app generates a short-lived code on your phone, based on a secret shared when you set up the account. The codes change every 30 seconds or so and do not travel by text message, which removes the SIM-swapping risk. Apps work offline, and many let you back up or transfer the setup. The weak point is that a person who tricks you into typing the current code on a fake page can use it right away, so the app does not fully resist phishing.
Setup is simple. Scan the code the service displays, check that the app now shows an entry for it, then enter the code once to confirm. Store your backup codes in a secure place, because losing the phone without a backup can lock you out. Many password managers can also store these one-time codes, which is convenient but means that a single compromised vault could expose both factors, so weigh that trade-off for your most sensitive accounts.
Security keys and passkeys
A security key is a small physical device that you plug into a computer or tap against a phone to approve a sign-in. It uses public-key cryptography that is bound to the real website, so it will not respond to a fake login page. This makes security keys the strongest of the common methods against phishing. Many services support them through standard protocols, and some also accept a passkey stored on your phone or in a password manager. Passkeys offer similar protection without a separate device and are increasingly common.
Security keys cost money and must be kept safe, because losing the only key can lock you out. Register at least two keys, keep one in a secure place and check that the service lets you add a backup method. Passkeys can be backed up through your device or manager, so review how your chosen platform stores them before relying on one.
Comparing the methods and choosing
The table below summarizes the trade-offs. Read it as a guide, not a ranking that applies to every person, because support and features vary by service.
Scroll sideways to see the full table →
| Method | Protection against phishing | Protection against SIM swapping | Convenience | Main weakness | Typical cost |
|---|---|---|---|---|---|
| Text message code | Low | Low | High, works on any phone | Codes can be intercepted or redirected | Usually free |
| Authenticator app | Medium | High | High, works offline | A code typed into a fake page can be used | Usually free |
| Security key or passkey | High | High | Medium, requires a device | Lost or damaged key without a backup | Varies by device |
For most people, a sensible approach is to use an authenticator app or a passkey for email, banking and any account that can reset other accounts. Use a security key for the most sensitive accounts if the service supports it. Use text codes only where nothing stronger is available, and move to a stronger method when the option appears. Setup steps and account recovery procedures differ by service, so check each provider's help pages for its current options, and confirm how to recover an account if you lose a device.