TOTP Generator with Countdown and otpauth URIs
Compute RFC 6238 TOTP codes from a base32 secret and build otpauth:// URIs for testing 2FA
For development and testing. Codes are computed in this tab with the Web Crypto API and the secret is never sent anywhere, but do not paste the 2FA secret of a real production account into any website, including this one. There is no share link on purpose.
Secret is empty.
otpauth://totp/TechLogHub%20Test:dev%40example.com?secret=&issuer=TechLogHub%20TestAuthenticator apps import this URI from a QR code. Many apps ignore non-default algorithm, digits or period values, so test with SHA-1, 6 digits and 30 seconds first.
How TOTP one-time passwords are generated
TOTP (Time-based One-Time Password, RFC 6238) is the algorithm behind the six-digit codes in Google Authenticator, Microsoft Authenticator, 1Password, Authy and most other 2FA apps. The server and the app share a secret key, usually shown to you once as a QR code or a base32 string like JBSWY3DPEHPK3PXP. Both sides then compute the same code independently from that secret and the current time, so nothing needs to be sent between them.
The steps are simple. Take the Unix time in seconds and divide by the period, normally 30, rounding down; that integer is the counter T. Compute an HMAC of T, written as an 8-byte big-endian number, using the secret as the key; SHA-1 is the default hash, with SHA-256 and SHA-512 as options. Then apply the dynamic truncation from RFC 4226 (HOTP): the low 4 bits of the last HMAC byte pick an offset, four bytes from that offset form a 31-bit integer, and that integer modulo 10^6 (or 10^8) is the code, zero-padded. This one time password generator does exactly that with the browser's Web Crypto HMAC implementation and shows the counter so you can follow along.
The implementation is checked against the test vectors in RFC 6238 Appendix B. For the SHA-1 test key "12345678901234567890" at T = 59 seconds with 8 digits the expected code is 94287082, and the SHA-256 and SHA-512 vectors (46119246 and 90693936) match as well.
Using this 2FA code generator for development and testing
The main use is building or debugging two-factor login. Generate a random secret (20 bytes for SHA-1, matching the RFC 4226 recommendation, or 32 and 64 bytes for SHA-256 and SHA-512), store it for a test user, and compare the code your server expects with the code shown here. The previous and next codes are listed too, because most servers accept one step either side to tolerate clock drift; if your server only matches the previous or next code, one of the clocks is off by roughly a period.
The otpauth:// URI builder produces the Key URI Format that authenticator apps read from QR codes: otpauth://totp/Issuer:account?secret=...&issuer=.... Algorithm, digits and period are added only when they differ from the defaults. Be aware that several popular apps ignore those three parameters and silently fall back to SHA-1, 6 digits and 30 seconds, so a mismatch between the app and your server is often caused by a non-default setting, not by your code.
Common causes of wrong codes: the secret was decoded as text instead of base32, the server clock is not synced with NTP, the period is 60 on one side and 30 on the other, or leading zeros were dropped because the code was stored as a number.
Keep real secrets off the web
Everything here runs locally: the secret stays in this browser tab, nothing is stored, and there is deliberately no share link. Even so, treat any website as the wrong place for the 2FA secret of a real account. Anyone who has that secret can produce your codes forever. Use this page with test accounts and generated secrets, and keep production secrets in a proper authenticator or password manager.
How to use the TOTP Generator with Countdown and otpauth URIs tool
- 1
Enter or generate a secret
Paste a base32 secret from your test setup or press Random to create a new one.
- 2
Match the server's settings
Choose the algorithm (SHA-1, SHA-256 or SHA-512), the number of digits (6 or 8) and the period (30 or 60 seconds).
- 3
Read the current code
Copy the current code before the countdown runs out; previous and next codes help diagnose clock drift.
- 4
Build an otpauth URI
Fill in issuer and account name and copy the otpauth:// URI to turn into a QR code for an authenticator app.
Frequently asked questions
Why doesn't my code match my authenticator app?
Check that the secret, algorithm, digits and period are identical on both sides and that your device clock is accurate. Many apps ignore non-default algorithm, digits or period values, so test with SHA-1, 6 digits and 30 seconds first.
Is it safe to enter my 2FA secret here?
The code runs only in your browser and the secret is never transmitted or stored, but you should not paste secrets for real production accounts into any website. Use test secrets.
What is the difference between TOTP and HOTP?
HOTP (RFC 4226) uses a counter that increases each time a code is used. TOTP (RFC 6238) derives the counter from the current time divided by a period, so codes expire automatically.
How was this TOTP generator verified?
Against the RFC 6238 Appendix B test vectors, for example the SHA-1 key 12345678901234567890 at T = 59 seconds must give 94287082 with 8 digits, along with the SHA-256 and SHA-512 vectors.
Related on TechLogHub
Related Security Tools
UUID Generator for v4 and v7 with Bulk Output
Generate v4 and v7 UUIDs in bulk and inspect any UUID or GUID
Hash Generator: MD5, SHA-256, SHA-512 and HMAC
Compute MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes and HMACs of text or files
Bcrypt Hash Generator and Verifier with Cost
Hash passwords with bcrypt at a chosen cost factor and verify passwords against bcrypt hashes
Password Generator with Passphrases and Entropy
Generate strong random passwords or word-based passphrases with an entropy meter
Chmod Calculator for Octal and Symbolic Modes
Convert Linux permissions between checkboxes, octal (755) and symbolic (rwxr-xr-x) and build the chmod command
Get the next tool before you need it
One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.

