Security & Privacy
2FA / TOTP Code Generator
Generate time-based one-time passwords (TOTP) from a Base32 secret — to test two-factor authentication setups, with SHA-1/256/512, 6–8 digits and custom periods.
How to use
- 1Paste the Base32 secret (the text under a 2FA QR code).
- 2The current code appears with the seconds left in this period. Press Calculate again for the next code.
How it's calculated
TOTP (RFC 6238) = HOTP(secret, floor(unix time ÷ 30)): an HMAC-SHA-1 of the time step, dynamically truncated to 6 digits. Everything runs in your browser.
Frequently asked questions
Is it safe to paste my real 2FA secret?
The code is computed entirely in your browser and nothing is sent anywhere, but treat 2FA secrets like passwords — use this for testing, not as your everyday authenticator.
Why doesn't my code match my app?
Check your device clock is correct, and that the digits, period and algorithm match the service's settings (almost always 6 digits, 30 s, SHA-1).
What is the Base32 secret?
When you set up 2FA, the QR code contains a secret like JBSWY3DPEHPK3PXP. Most sites also show it as text for manual entry.
What's actually happening behind the six digits
TOTP doesn't store a list of codes anywhere — it derives one deterministically from the shared secret and the current time. The generator decodes your Base32 secret to raw bytes, divides Unix time by the period (30 seconds by default) to get a counter, computes an HMAC of that counter using the secret as the key, and then "dynamically truncates" the hash: it takes the last nibble of the HMAC output as an offset, reads 4 bytes starting there, masks off the top bit, and reduces the result modulo 10^digits. Both your phone's authenticator app and this generator run that exact algorithm (RFC 6238), which is why two independent devices land on the same code without ever talking to each other.
Worked example: 2FA / TOTP Code Generator
RFC 6238's published test vector uses the secret "12345678901234567890" (Base32: GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ) with SHA-1, 8 digits, and a 30-second period. At Unix time 59, the counter is floor(59/30) = 1, and the algorithm produces the code 94287082 with 1 second left in that period — plug those exact inputs into the fields above and you'll get that exact code, which is how this implementation is verified against the spec rather than just "looking right."
Why your code sometimes doesn't match
Three things have to line up exactly: the digit count, the period, and the algorithm (almost every consumer service uses 6 digits / 30 seconds / SHA-1, but some enterprise tools use SHA-256 or a 60-second period). If those match and the code still looks wrong, the usual culprit is clock drift — TOTP has no tolerance for your device's clock being off by more than about half a period, which is why authenticator apps sync time with a time server rather than trusting the phone's clock alone.
A blank clock uses this moment, and a blank period is 30 seconds
The secret box starts as JBSWY3DPEHPK3PXP. A secret that does not decode to at least one byte is rejected and asks you to enter the secret. Digits start at 6, with 7 and 8 available. Period starts at 30 seconds and cannot go below 1. A blank period, or zero, is treated as 30, and a fraction is taken as a whole number of seconds. Unix time starts empty, which means the current second on this device. Fill it in and both the current code and the next code are computed at that instant instead. Seconds left is whatever remains in the period. The next code is exactly one period ahead of the time you used.
Related tools
- Credit Card Number Validator
Check whether a card number is correctly formatted — Luhn checksum, length and card brand (Visa, Mastercard, Amex, Discover…). For testing forms; nothing is stored or sent.
- Password Policy Generator
Generate a clear, modern company password policy based on NIST SP 800-63B — length, MFA, breached-password screening, lockouts and password managers.
- Random MAC Address Generator
Generate random, valid MAC addresses (locally administered, unicast) for testing, virtual machines and network privacy — in any common format.
- How to Delete Your Accounts (Per App)
Where to find the delete-account option in popular apps — Facebook, Instagram, TikTok, X, Snapchat, Google, Amazon, LinkedIn, Reddit, Discord and more.
- Driving Theory Test Practice Quiz (UK & US)
Practise for your driving theory or permit test with free multiple-choice questions on the UK Highway Code or common US road rules — speed limits, stopping distances, signs, right of way and more, with explanations.
- JSONPath Tester
Query JSON with JSONPath expressions like $.store.book[*].author or $..price and see every match with its exact path.