Code2FA
EN
EnglishTiếng Việt中文РусскийEspañol

What is a 2FA code? TOTP vs SMS OTP vs email codes

Code2FA team · Updated · 2 min read

What is a 2FA code? TOTP vs SMS OTP vs email codes

A 2FA code is the second lock after your password. Here is what the different kinds of codes are, how they work, and which one you should use.

What does 2FA mean?

2FA (two-factor authentication) means you prove it is you with two different kinds of evidence when you sign in:

  • Something you know: your password.
  • Something you have: your phone, an authenticator app, a security key.
  • (Or something you are: fingerprint, face.)

If someone steals your password through a data breach, phishing page or malware, they still can't get in without the second factor. Google and Microsoft both report that 2FA blocks the vast majority of automated account takeovers.

The common types of 2FA codes

1. TOTP codes from an authenticator app

This is the familiar "6 digits that change every 30 seconds" (Google Authenticator, Microsoft Authenticator, 2FAS, Aegis…). When you enable 2FA, the site gives you a secret key, usually inside a QR code. The app stores the key and every 30 seconds computes a new code from key + current time, as defined in RFC 6238.

Secret keystored in the app Current time÷ 30 seconds HMAC-SHA1+ truncate 482 913
Same secret + same moment = same code on every device. No network needed.

Because only the key and a clock are needed, TOTP codes work without signal or internet, can't be intercepted in transit, and nobody "sends" them to you.

2. SMS one-time passwords

The site texts a random code to your number. Convenient, but the weakest option: attackers can hijack your number with a SIM swap, intercept messages, or simply trick you into reading the code out. More: Is SMS OTP safe?

3. Email codes

Same idea, delivered by email. Exactly as safe as your inbox: if your email is compromised, every account using email codes falls with it.

4. Push prompts, security keys and passkeys

Some services show an "Is this you signing in?" prompt on your phone. Strongest of all are hardware security keys (YubiKey etc.) and passkeys: they check the real domain, so phishing pages can't use them. See What is a passkey?

Which one should you use?

MethodSecurityNotes
Security key / passkeyVery highPhishing-resistant; not supported everywhere yet
Authenticator app (TOTP)HighMost widely supported; back up your keys
Push promptGoodBeware of approving a prompt you didn't start
EmailMediumOnly as strong as your email account
SMSLowestStill far better than nothing

In practice: use an authenticator app for most accounts, add passkeys where offered, and always save your backup codes (how to store them).

When is a tool like Code2FA useful?

A phone app is enough for most people. But if you manage many accounts, work on a computer, or need a code from a secret key without your phone nearby, Code2FA computes codes right in your browser: paste a key (or a whole ID|Pass|2FA list) and the codes appear. Keys are never uploaded.

FAQ

How long is a 2FA code valid?

TOTP codes usually change every 30 seconds. Many servers also accept the previous and next code to allow for delays, so in practice a code works for about 30–90 seconds.

Is 2FA the same as 2-step verification?

For everyday purposes, yes. Google calls it 2-Step Verification and Facebook calls it two-factor authentication; both mean a second check after your password.

How can I get a 2FA code without my phone?

If you still have the secret key, paste it into Code2FA on any computer to get the code. If you don't, use a backup code or the service's account recovery process.

Related articles