What is OTP Code Generator?
OTP Code Generator — An OTP Generator is a free tool that creates one-time passwords and TOTP/HOTP codes for two-factor authentication testing and development.
Loading your tools...
Generate RFC 6238 time-based one-time passwords (TOTP) for two-factor authentication testing. Create setup QR codes for Google Authenticator, Authy, Microsoft Authenticator, and other 2FA apps. Configure secret keys, time periods, digit count, and hash algorithms (SHA-1, SHA-256, SHA-512).
OTP Code Generator: Enter a secret key or generate one to create time-based (TOTP) or counter-based (HOTP) one-time passwords. The 6-digit code refreshes every 30 seconds. Useful for testing 2FA implementations.
Generate and validate time-based OTP (one time password) for multi-factor authentication. totp generator, totp qr code generator.
Secret in hexadecimal
9f46f04e3d53f4877017
Epoch
1780307250
Iteration — Count
59343575
Padded hex
00000000038982d7
OTP Code Generator — An OTP Generator is a free tool that creates one-time passwords and TOTP/HOTP codes for two-factor authentication testing and development.
Enter an existing Base32 secret key, or click Generate to create a new one.
Configure settings: time period (30s default), digits (6), and hash algorithm (SHA-1).
View the current TOTP code with countdown timer, plus previous and next window codes.
Scan the QR code with Google Authenticator or Authy to verify your 2FA implementation works.
Testing two-factor authentication implementations in web and mobile apps
Generating TOTP setup QR codes for authenticator app enrollment flows
Debugging OTP mismatch issues caused by clock drift or configuration errors
Validating 2FA backup and recovery workflows during security audits
TOTP combines a shared secret key (Base32-encoded) with the current Unix timestamp divided by a time period (typically 30 seconds) to produce a counter value T = floor((current_time - T0) / period). The tool then computes HMAC(secret, T), truncates the result via dynamic offset to a 31-bit integer, and takes that integer modulo 106 (or 108) to produce a 6 or 8-digit code. Both the server and the authenticator app perform this calculation independently — if the codes match, authentication succeeds. The standard allows for a ±1 window tolerance (server accepts the previous and next code as well) to handle minor clock drift between devices.
When you scan a 2FA QR code, it encodes an otpauth:// URI in this format: otpauth://totp/Issuer:account@example.com?secret=BASE32SECRET&issuer=Issuer&algorithm=SHA1&digits=6&period=30. The Issuer:account path is what appears in your authenticator app as the entry name. The query parameters tell the app how to compute codes — most apps default to SHA-1 / 6 digits / 30 seconds if those parameters are omitted (matching Google Authenticator's original 2010 implementation). For HOTP, the URI uses otpauth://hotp/... with a counter= parameter instead of period=.
SHA-1 is the universal default — every authenticator app supports it, and it's what Google Authenticator originally implemented. Despite SHA-1 being deprecated for collision-resistance applications (TLS, digital signatures), HMAC-SHA1 remains cryptographically secure for TOTP because HMAC's security relies on PRF behavior, not collision resistance. SHA-256 and SHA-512 are stronger algorithms used by some enterprise systems (e.g., Microsoft Authenticator Premium, some banking 2FA). Compatibility caveat: if you select SHA-256 or SHA-512, the authenticator app must also support that algorithm — Google Authenticator (the original Android version pre-2020) and many older apps only support SHA-1.
When 2FA codes don't match, check in this order:(1) Device clock sync — open Settings → Date & Time and enable Automatic / NTP. Even 30 seconds of drift will desync codes. (2) Base32 secret encoding — Base32 is case-insensitive but padding (=) and lowercase variations cause silent failures. (3) Hash algorithm mismatch — SHA-1 vs SHA-256 produce completely different codes from the same secret. (4) Time period — most services use 30 seconds; some use 60. (5) Digit count — 6 vs 8 digits. (6) Counter desync (HOTP only) — if you press "next code" in your app more than the server expects, codes drift permanently.
TOTP is a shared-secret system — both the server and your authenticator app know the same Base32 secret. This means TOTP is vulnerable to phishing (an attacker who tricks you into typing a code into a fake login page can replay it within 30 seconds) and to server-side database breaches (if an attacker steals the secret, they can generate codes forever). WebAuthn / passkeys use public-key cryptography — the server only stores a public key, and the private key never leaves your device. Best practice for high-value accounts: use passkeys / WebAuthn as the primary 2FA, with TOTP as a backup. For everything else, TOTP is dramatically better than SMS-based 2FA (which is vulnerable to SIM-swap attacks).
Developers building 2FA into their app use this to test setup flows end-to-end without needing a real authenticator app. QA teams use the previous / current / next window display to debug clock-drift bugs in TOTP verification code. Support teams use it to recover stuck accounts where a user has the secret but lost their authenticator app. Security researchers and red teams use it to verify TOTP implementations against RFC 6238 reference vectors.