2FA Code Generator
Generate TOTP two-factor authentication codes from your secret key
Enter your secret key to generate 2FA codes. The secret key is usually provided when you enable two-factor authentication on services.
The secret key is never sent to our server. Decoding, hashing and code generation all happen in JavaScript on your device. Read the limitations below before using this for an account that matters.
How TOTP actually produces a 6-digit code
TOTP (Time-based One-Time Password, RFC 6238) is not random, and nothing is transmitted when a code appears. Your device and the server hold the same shared secret and each compute the same answer independently — two parties that never talk to each other land on the same six digits because they run identical arithmetic on identical inputs.
Those inputs are the secret and the clock. The Unix timestamp is divided by 30 and rounded down, giving a counter that increments once every 30 seconds. The counter goes into an 8-byte block and through HMAC-SHA1, keyed with the decoded secret, producing a 20-byte hash.
Dynamic truncation then extracts the digits: the low 4 bits of the final hash byte give an offset, 4 bytes are read from there, the top bit is masked off, and the result is taken modulo 1,000,000. Since the counter only changes every 30 seconds, a code stays identical for its whole window then changes completely — it never drifts gradually.
This page recomputes that once per second, so the digits change the instant a new window opens.
Where the Base32 secret key comes from
The secret is issued once, by the service you are protecting, at the moment you turn two-factor authentication on. It cannot be derived, recovered or guessed afterwards.
- If you are shown a QR code, look for a link labelled "Can't scan it?", "Enter this text code" or "Set up manually". That reveals the same secret as a text string.
-
The QR code itself just encodes an
otpauth://totp/...URL. Thesecret=parameter inside it is the Base32 key — paste only that value, not the whole URL. -
A valid secret uses the Base32 alphabet only: letters
A–Zand digits2–7. It never contains0,1,8or9. Spaces, hyphens and trailing=padding are stripped automatically, sojbsw y3dp ehpk 3pxpandJBSWY3DPEHPK3PXPbehave the same.
Most services show the secret exactly once. If you lose it along with your authenticator, no tool can regenerate it — you go through account recovery and set 2FA up again. Save your backup codes at the same time.
Why the code is rejected, and how to fix it
A generated code that the service refuses almost always points at one of these, roughly in order of how often it happens:
- Your device clock is wrong. By far the most common cause. Codes come from your local time, so an offset of more than about 30 seconds puts you in a different window than the server — a 10-minute drift is invisible in daily use but breaks TOTP completely. Enable automatic network time (Windows and macOS: Date & Time → set automatically; Android/iOS: Date & Time → Automatic), then reload this page.
-
A transcription error in the secret. Confusing
Owith0, orIwith1, is easy. Because Base32 excludes those digits, a wrong character either triggers the invalid-key error or silently decodes to a different key that yields plausible but always-wrong codes. - You submitted the code too late. If a code appears with four seconds left on the timer, wait for the next one. Most servers accept the previous window as well, but not all of them do.
- The service does not use standard TOTP. A few issuers use HOTP (counter-based, not time-based), a non-30-second period, 8-digit codes, or SHA-256. Those will never match here — see the support table below.
- The secret belongs to a different account. If you set up 2FA on several services, each has its own secret. Nothing in the key itself identifies which account it came from, so a mislabelled key fails with no useful error.
When you should not use a web-based generator
An honest assessment: a web page is a worse place to keep a 2FA secret than a dedicated app, and for some accounts you should not use this tool at all.
Two-factor authentication works because the second factor lives somewhere separate from the first. Signing in on this computer while also generating the code on this computer, in a browser, weakens that separation badly — anything that can read your browser (a malicious extension, clipboard-reading malware, someone at your unlocked machine) can potentially capture both factors at once.
This page keeps the secret in memory only: nothing is sent to our server or written to local storage, and it is gone when you close the tab. Better than storing it, but the secret still passes through the page and your clipboard on the way.
Where this tool is genuinely reasonable: confirming a secret you just wrote down actually decodes before you rely on it; reaching a low-stakes account after losing your phone when you still hold the backup secret; testing a TOTP implementation you are building. Verification and low-value cases — not daily use on accounts that matter.
What this tool supports, and what it does not
This generator implements one specific configuration — the default that the large majority of services use. Knowing the boundaries saves you debugging a key that was never going to work:
Supported: 30-second time step, HMAC-SHA1, 6-digit output, Base32-encoded secrets of any length, with spaces, hyphens and = padding tolerated. This covers Google, Facebook, Instagram, GitHub, Amazon, Microsoft, Discord, Cloudflare and nearly every other mainstream issuer.
Not supported: HOTP (counter-based) keys, SHA-256 or SHA-512 variants, periods other than 30 seconds, 7- or 8-digit codes, Steam's alphanumeric alphabet, proprietary schemes such as RSA SecurID, and push-approval 2FA (Duo, Okta Verify), which has no secret key at all. There are no settings here to change algorithm, digit count or period.
Since the calculation is local, codes keep generating with no network connection once the page has loaded. The trade-off: an accurate device clock is entirely your responsibility — nothing here can detect or correct an offset.
Frequently asked questions
Is my secret key sent to your server?
No. Base32 decoding, HMAC-SHA1 and code generation all run in JavaScript on your device, and the page makes no network request when you generate a code. You can check this yourself: open developer tools, switch to the Network tab, and watch that nothing is sent when you click Get Code.
Why does my code not work even though the secret is correct?
Check your device clock first — it explains the large majority of cases. Codes are computed from local time, so an offset beyond roughly 30 seconds puts you in the wrong window and everything is rejected. Enable automatic network time and reload. If the clock is right, suspect a mistyped character or a non-standard algorithm.
Can this replace Google Authenticator for everyday use?
It produces identical codes, but we would not recommend it for your main accounts. A dedicated app keeps secrets in device-bound encrypted storage behind a lock screen and survives a closed tab. Treat this page as a verification and fallback tool.
I lost my phone and never saved the secret. Can this recover my codes?
No. Without the original secret there is nothing to compute from, and it cannot be brute-forced or derived from your account. Use the backup codes issued at setup, or the service's account recovery process. Once back in, re-enable 2FA for a fresh secret and save the backup codes separately.
Why can my first code expire almost immediately?
Codes are tied to absolute time, not to when you opened the page. The 30-second windows are fixed slices of the Unix clock, so the first one you see is usually partial — load the page 20 seconds into a window and that code lasts only 10 seconds. The bar shows the time left in the real window.