Need the six-digit number your phone shows, without hunting for the phone? This TOTP code generator turns your secret key into live TOTP tokens that match Google Authenticator and Authy, refreshing on its own so you can copy a valid code and finish in seconds.
TOTP code generator basics: two-factor authentication codes
A time-based one-time password is a short, single-use number that proves you hold a key without ever sending it. Under RFC 6238, the IETF standard behind it, your device and the server share a key, feed it through HMAC together with the current time, and keep a truncated slice of the result as a few digits. Every OTP is temporary and will expire within moments, so a stolen code is nearly worthless to an attacker. That extra step is why two-factor logins hold up even when a reused credential leaks.
The shared secret carries the entropy, while the clock supplies the changing input. An online one-time password generator such as this one does identical math inside your browser, so security rests on keeping that shared secret private.
How this 2FA code generator reads your base32 secret
Paste the base32 secret from the service's setup screen and the page does the rest. It counts how many whole intervals of one period have passed since the Unix epoch, using the current timestamp:
\(T = \lfloor t / 30 \rfloor\)
Each time step lasts 30 seconds, and both sides derive matching tokens for the same value of \(T\). Click the digits to copy the 2FA code to your clipboard, then paste it into the login form.
You can check the arithmetic by hand. At Unix time 1,700,000,000 the division gives \(T = 56{,}666{,}666\) with a remainder of 20, so the current code has 10 seconds left before \(T\) increases by one and everything changes. The published test vector goes further: the ASCII key 12345678901234567890 at Unix time 59 gives \(T = 1\) and the 8-digit code 94287082. If a generator cannot reproduce that number, its math is wrong, not your key.
To generate a code from start to finish:
- Copy the key from the screen where you enrolled the account.
- Paste it into the field above and choose the hash and the number of digits.
- Wait for the live code to appear, then compare it with your phone if you want a cross-check.
- Copy the code and submit it before the ring empties.
Scan a QR code or paste your secret key
If the service displays a QR code, upload a screenshot or scan it; otherwise choose manual entry and type the key printed beneath it. Both routes give you the same string, because a QR code is only a wrapper around it.
Read the 30-second countdown
The progress ring shows how long the current code lives. When it reaches zero a fresh code replaces it and the old one expires, so copy the digits before the timer resets. A 30-second window is the RFC default.
Extract the secret from an otpauth URI
Some services hand you an otpauth:// link rather than plain text. Copy the value after secret=; it is the base32 string this tool expects, and the issuer and account name in the URI are only labels. Leave them out if you like; they never change the code.
SHA-1, SHA-256 or SHA-512 for a TOTP authenticator
Pick the algorithm your service uses. If the algorithm differs on the two sides, each produces a different token every time, even with the same key and clock. Match the number of digits too.
| Hash or length | Typical choice | When it fits |
|---|---|---|
| SHA-1 | Default | Nearly every consumer app |
| SHA-256 | Stricter | You control the client and server |
| SHA-512 | Strongest | Rarely supported, so check first |
| 6 digits | Common | Best balance of ease and strength |
| 8 digits | Optional | Only if the service asks for it |
6 digits or 8 digits
Stay with six unless the service says otherwise, since the extra length rarely repays the typing effort on a phone keypad. An 8-digit OTP adds a little entropy but few consumer apps accept it, so match the digit length your account expects. Changing the length does not change the underlying number, only how many of its trailing digits are shown.
Checking a staging account with this TOTP code generator
A QA engineer enrolling a staging account has one question: will the code the build server derives be accepted at login? Her service shows the base32 key UVG4UGBFGC5R23ITFTPNMI33F3MR4P3S and says SHA-1 with 6 digits, so she pastes it into this TOTP code generator, leaves those defaults alone and notes the time.
At Unix time 1,794,484,321 the division gives \(T = 59{,}816{,}144\) with a remainder of 1, so the window just opened and 29 seconds remain. The tool shows 932874. She cross-checks the neighbouring windows by hand: the previous one gives 978623 and the next 384158, and RFC 6238 advises servers to tolerate exactly one step on either side. Her phone's authenticator shows 932874 as well, so the algorithm and key agree.
| Change | Code shown | Accepted? |
|---|---|---|
| Nothing (baseline) | 932874 | Yes |
| Hash switched to SHA-256 | 720872 | No |
| Test runner clock 47 seconds slow | 549516 | No |
The sensitivity rerun is what she cares about. Switching the hash to SHA-256 changes the OTP completely, which is the quickest way to spot a settings mismatch. A clock that runs 47 seconds slow lands two steps back, outside the one-step grace, so the login fails even though the key is right. The number to watch is the clock offset, not the key: anything beyond 30 seconds is a failure, and a drift of 31 to 59 seconds can pass or fail depending on where in the window the request lands.
That edge case is where this tool's answer should not be trusted alone. A matching code proves the key and settings, not the runner's clock. Her next action is concrete: sync the test runner with a network time source, rerun, and only then commit the key to the pipeline vault.
Authenticator apps and Google Authenticator compatibility
Every major authenticator app runs the same RFC 6238 math, which is why a code made here matches the one on your phone. You can store the same key in several of them:
- Microsoft Authenticator imports a key by manual entry or camera.
- 1Password and Bitwarden keep the key beside the saved entry.
- Authy syncs the 2FA key across your devices.
Automating an OTP in end-to-end test automation
QA teams stall when a login flow demands a code from a physical phone. A generator removes that dependency: keep the key in your CI vault, derive the OTP at run time, and your e2e tests stay green. Debugging gets easier too, since you can compare your token with the one a failing run produced. Many teams wrap the logic in an API endpoint, though a library or REST API works just as well for testing.
Security tips for your secret
Treat the key like a password, never paste it into chat, and store backup codes offline so account recovery stays possible. Prefer a passkey where one is offered, since it resists phishing. If you ever suspect the key was exposed, remove the device from the account and enroll again so a new key replaces the old one.
Fixing a verification code that does not match
When a code from this generator is rejected, the cause is almost always clock skew: compare it with your phone, sync both clocks and let your service accept one step on either side. Phones usually sync automatically, but a laptop that has been asleep for days can drift by a minute or more, which is enough to miss the window. Then confirm the algorithm and digit length agree. This generator uses the Web Crypto engine in your browser and computes locally, so you can retest as often as you need while you debug.
Frequently Asked Questions
- How does this tool compute the code?
- It follows RFC 6238 (TOTP) exactly: your Base32 secret is decoded to bytes, combined with the current time divided into 30-second (or custom) intervals via HMAC (SHA1, SHA256, or SHA512, computed with the browser's native Web Crypto API), then truncated down to a 6- or 8-digit code the same way every authenticator app does. The algorithm was verified against the official RFC 6238 test vectors during development.
- Why does the code sometimes look wrong or not match my app?
- The most common cause is a clock mismatch -- TOTP codes are time-based, so if your device's clock has drifted, the computed code won't match. Also double-check the algorithm, digits, and period match what the service actually issued you; most use the defaults (SHA1, 6 digits, 30 seconds), but a few don't.
- Is it safe to paste my 2FA secret into this tool?
- The secret is used entirely in your browser to compute the code locally -- it is never transmitted, logged, or stored anywhere, and disappears the moment you reload the page. That said, treat any TOTP secret as sensitive: anyone with it can generate valid codes for your account, so only use this on a device you trust.
- What is this tool useful for?
- Verifying an authenticator-app setup without needing your phone in hand, debugging a TOTP integration you're building, or checking that a secret and its resulting codes are actually correct before rolling it out.
- Why does the code change right as the ring empties?
- That's expected -- the ring shows how much of the current 30-second (or custom-period) window is left. When it fully drains, the time counter increments and a brand new code is computed, exactly matching how your physical authenticator app behaves.