How to use it
Paste either a Base32 secret (the text shown under “can’t scan the QR code?”, such as JBSW Y3DP EHPK 3PXP) or a full otpauth://totp/… URI into the left pane. Spaces, hyphens and lowercase letters in the secret are fine.
- With a raw secret, the Digits (6 or 8), Period (30 or 60 seconds) and Algorithm (SHA-1, SHA-256, SHA-512) options apply. Issuer and Account go into the generated
otpauth://URI. - With a URI, its own
algorithm,digitsandperiodparameters are used (defaults SHA1, 6 and 30), and the issuer and account are read from the label.
Example output
The default sample at 2026-10-01 09:00:12 UTC, with Issuer Tidypane and Account linh@example.com:
Current code 615220
Valid for 18 s (until 2026-10-01T09:00:30Z)
Next code 211463
Settings SHA1 · 6 digits · 30 s period
otpauth://totp/Tidypane:linh%40example.com?secret=JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP&issuer=Tidypane&algorithm=SHA1&digits=6&period=30
How TOTP works
TOTP (RFC 6238) is HOTP (RFC 4226) with a counter that comes from the clock:
- Counter = ⌊Unix time ÷ period⌋. At 09:00:12 with a 30-second period, every device in the world gets the same counter until 09:00:30.
- HMAC of the counter (8 bytes, big-endian), keyed with the decoded secret, using SHA-1, SHA-256 or SHA-512.
- Dynamic truncation: the low 4 bits of the last HMAC byte pick an offset, and 31 bits are read from there.
- Code = that number mod 10^digits, padded with leading zeros.
The implementation is tested against every test vector in RFC 6238 Appendix B (all three hash algorithms, including times after 2038) and the HOTP vectors in RFC 4226 Appendix D.
Common errors
- “Invalid Base32 character at position 8”. Base32 uses only A–Z and 2–7. A
0,1,8or9usually means the secret was misread from a screen: tryO,I/LorBinstead. The message gives the position but never repeats the secret. - “The secret length is invalid for Base32”. A character is missing or extra. Copy the secret again.
- “This is an HOTP (counter-based) URI”.
otpauth://hotp/secrets use a counter, not the time. This tool only generates TOTP. - Warning “The secret is only 80 bits”. A 16-character secret is 80 bits. RFC 4226 requires at least 128 bits and recommends 160 (32 Base32 characters), which is what most providers issue.
Equivalent code
import pyotp
totp = pyotp.TOTP("JBSWY3DPEHPK3PXPJBSWY3DPEHPK3PXP")
print(totp.now())
print(totp.provisioning_uri(name="linh@example.com", issuer_name="Tidypane"))
// Node.js, no dependencies: secret is the Base32-decoded Buffer
import { createHmac } from 'node:crypto';
function totp(secret, now = Date.now(), period = 30, digits = 6) {
const msg = Buffer.alloc(8);
msg.writeBigUInt64BE(BigInt(Math.floor(now / 1000 / period)));
const mac = createHmac('sha1', secret).update(msg).digest();
const off = mac[mac.length - 1] & 15;
return String((mac.readUInt32BE(off) & 0x7fffffff) % 10 ** digits).padStart(digits, '0');
}
TOTP usually sits on top of a password check. See the Bcrypt Generator for storing passwords and the Password Generator for creating them. To enroll a test account in an authenticator app, paste the generated otpauth:// URI into the QR Code Generator and scan the result.
Frequently asked questions
Why doesn't my code match the authenticator app?
Usually the clock or the settings. TOTP depends on the current time, so check that your computer's clock is synced. Then check that algorithm, digits and period match what the service uses. Some apps ignore non-default settings and quietly fall back to SHA-1, 6 digits and 30 seconds.
Does the code refresh by itself?
The code is computed when the tool runs. The output shows how many seconds it stays valid and the next code. To get a fresh code, edit the input or change an option. Most servers also accept the previous and next code to allow for clock drift.
What is the otpauth:// URI for?
It is the Key URI Format that authenticator apps read from QR codes. It carries the secret, a label (issuer and account) and the settings. Turn the URI into a QR code with the QR Code Generator to enroll a test account in an app.
Can I use this as my everyday authenticator?
It is meant for development and debugging: checking a secret, testing a server's TOTP check, or seeing which settings a provider uses. For real accounts, keep secrets in an authenticator app or password manager. A secret pasted into a web page is only as safe as that device.
Is the secret sent anywhere?
No. Codes are computed in your browser with the Web Crypto API. The tool is marked sensitive, so the secret is never saved as a draft or put into a share link.
Last updated