Generator/What is 2FA

What 2FA is, and what the six digits actually are

Two-factor authentication asks for two different kinds of evidence instead of one. A password is something you know, and it can be guessed, reused or stolen in a breach. The second factor is something you have, which an attacker with your password still does not.

The three second factors, and how they differ

Almost every service offers one of three, and they are not equally strong.

  • A code by SMS. The weakest of the three. Text messages can be intercepted, and a SIM-swap — persuading a carrier to move your number to another device — hands the attacker your second factor without touching your phone. Better than nothing, and worth leaving on if it is all a service supports.
  • An authenticator code (TOTP). The six digits this site generates. Nothing is transmitted and nothing depends on your carrier, because both sides compute the code from a shared secret and the clock. This is the sweet spot of security and availability for most people.
  • A passkey or security key (FIDO2/WebAuthn). The strongest, because it is phishing-resistant: the key checks which site is asking before it responds, so a fake login page gets nothing. If a service offers this and you can use it, prefer it.

How a TOTP code is worked out

TOTP is defined in RFC 6238, and the mechanism is simpler than it looks. At enrollment the service gives you a secret key. From then on, both sides do the same arithmetic: take the current Unix time, divide it into 30-second steps, run the step number and the secret through HMAC-SHA1, and truncate the result to six digits.

Two consequences follow, and they explain most of what confuses people. Nothing is sent when a code is generated — your authenticator never talks to the service, which is why it works on a plane. And the code depends on the clock, so a device more than roughly thirty seconds out of step produces digits the service rejects even though the key is perfectly correct. That is the single most common cause of a code being refused.

TOTP and HOTP

You may see HOTP mentioned alongside it. HOTP counts events instead of time: each code advances a counter. It is rare today because the counter drifts out of sync if you generate codes you never use. TOTP replaced it by using the clock as a counter both sides already agree on.

What the setup key is

The QR code you scan at enrollment is not magic — it is a text link. Decoded, it reads roughly otpauth://totp/GitHub:[email protected]?secret=JBSWY3DP...&issuer=GitHub. The secret is the shared key, usually 16 or 32 characters drawn from A–Z and 2–7, which is Base32. Everything else in the link is a label or a parameter.

Treat that key the way you would treat a password that can never be changed quietly. Anyone who has it can produce valid codes for the account indefinitely, and rotating it means re-enrolling at the service. It is also why keeping the text key at enrollment matters: a key you hold can be added to a second device later, while a QR code you scanned once and never saved cannot.

Most services hide the text behind a link on the QR screen — “can’t scan the QR code?” or “enter this key manually”. The setup guides name where each one puts it.

What 2FA does not protect you from

Codes defend against a specific thing: someone who has your password. They stop credential stuffing, reused passwords surfacing in a breach, and casual guessing. That is a large share of real-world account takeover, which is why turning 2FA on is worth the friction.

They do not defend against handing the code to the wrong person. A convincing fake login page can ask for your password and your code, then use both on the real site inside the same 30-second window. Nor do they help if malware is already on the device, or if an attacker takes over the account recovery path — an email inbox with no 2FA of its own is often the weakest link in the chain.

The practical response is to protect the recovery path as carefully as the account, keep the recovery codes a service issues at enrollment, and use passkeys where they are offered.

Where a browser generator fits

Because TOTP has no registration step, any authenticator holding your key produces the same code. That is what lets Gen2FA generate a working code from a key you paste, with no account and no install — useful at a keyboard, or when the phone with your authenticator is flat, lost or elsewhere.

It is not a replacement for an authenticator app, and this site says so in its disclaimer rather than pretending otherwise. An app is a vault that survives a cleared browser and keeps keys off the machine you browse on. Keep one enrolled. Compare the two approaches on the alternatives pages.

Questions

What does 2FA stand for?
Two-factor authentication. It means proving who you are with two different kinds of evidence rather than one: something you know, such as a password, plus something you have, such as a phone or a security key. Multi-factor authentication (MFA) is the same idea with two or more factors.
Why does the 2FA code change every 30 seconds?
Because the code is computed from the current time. TOTP divides time into 30-second steps, combines the step number with your secret key using HMAC, and truncates the result to six digits. A new step means a new code. Nothing is sent anywhere when the code changes — both your authenticator and the service work it out independently.
Is 2FA the same as OTP?
Not quite. OTP means one-time password, which is the code itself. 2FA is the wider idea of requiring a second factor, and a one-time password is the most common way to satisfy it. A TOTP code is a one-time password derived from the time; an SMS code is a one-time password delivered by text.
What is the setup key or secret key?
It is the shared secret both sides use to compute codes, usually shown as 16 or 32 characters of A to Z and 2 to 7 (Base32). The QR code at enrollment is just that key wrapped in an otpauth:// link along with the account name and parameters. Anyone holding the key can generate valid codes indefinitely, which is why it should be treated as a credential rather than a convenience.
Can two authenticators show the same code at once?
Yes, and that is normal. TOTP has no registration step: any authenticator holding the same key produces the same digits at the same moment. Enrolling a second device is a deliberate way to avoid being locked out if the first one is lost.
Does 2FA stop phishing?
Not on its own. If you are tricked into typing your code on a fake site, an attacker can relay it to the real one within the same 30-second window. Codes protect against stolen or reused passwords, not against handing credentials to the wrong site. Only phishing-resistant factors such as passkeys and FIDO2 security keys defend against that, because they check the site’s origin before responding.

Next