OTP Code Generator and Validator
Generate and validate TOTP codes compatible with Google Authenticator and other authenticator apps.
OTP Code Generator and Validator tool
Example
Input: Open the Generate tab (a new Base32 secret is created automatically)
Result: A 32-character Base32 secret, a QR code for authenticator apps and a 6-digit code that changes every 30 seconds
The code is HMAC-SHA1 of the current 30-second time step, truncated to 6 digits. With the RFC 6238 test secret GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ, Unix time 59 gives 287082.
RFC 6238 Test Values (6 Digits)
| Unix time | UTC time | Time step | Code |
|---|---|---|---|
| 59 | 1970-01-01 00:00:59 | 1 | 287082 |
| 1111111109 | 2005-03-18 01:58:29 | 37037036 | 081804 |
| 1111111111 | 2005-03-18 01:58:31 | 37037037 | 050471 |
| 1234567890 | 2009-02-13 23:31:30 | 41152263 | 005924 |
| 2000000000 | 2033-05-18 03:33:20 | 66666666 | 279037 |
| 20000000000 | 2603-10-11 11:33:20 | 666666666 | 353130 |
Computed with this tool algorithm for secret GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ; each is the last 6 digits of the RFC SHA-1 value.
- In Generate mode, use the random Base32 secret created for you, or click "Generate New Secret".
- Enter an issuer and account name to label the entry in authenticator apps.
- Watch the current code and the countdown to the next one.
- Scan the QR code with Google Authenticator or another TOTP app to add the account.
- To check a code, switch to Validate, enter the Base32 secret and the 6-digit code, and click "Validate Code".
How TOTP Codes for Authenticator Apps Work
This tool creates a TOTP secret and shows its live 6-digit code with a countdown. It also makes a QR code you can scan into Google Authenticator, Microsoft Authenticator, Authy or similar apps. A Validate tab checks whether a code matches any Base32 secret you enter.
TOTP (time-based one-time password, RFC 6238) needs only two things: a shared secret and the clock. Every 30 seconds, your app and the server each count the 30-second steps since 1970. They run that number through HMAC-SHA1 with the secret and cut the result down to 6 digits. The two sides never talk to each other, which is why codes work on a phone in airplane mode. It also means a phone clock that is a minute or more off can produce codes the server rejects.
New secrets are 32 Base32 characters (the letters A to Z and the digits 2 to 7), which is 160 bits, the size RFC 4226 recommends. The QR code holds an otpauth:// link with your issuer and account name. It also sets SHA1, 6 digits and a 30-second period, the settings nearly every app expects. The validator accepts the previous, current and next code to allow for clock drift.
Developers use the tool to test 2FA sign-up and login, or to find out why codes never match. Common causes are a secret copied with a typo or a server clock out of sync. A library set to a different period or number of digits is another. The tool can only make codes for a secret you already hold, so it cannot get anyone past 2FA on an account they do not control.
Everything runs in your browser. Still, treat a TOTP secret like a password, because anyone who has it can make valid codes. Avoid pasting secrets for important real accounts into any website. For other random secrets, try the Token Generator.
Sources
Frequently Asked Questions
Related Tools
Password Generator
Generate strong, secure passwords with customizable length, character types, and multi-word passphrases.
Security and EncryptionToken Generator
Generate random tokens and strings in hex, alphanumeric, URL-safe, and custom character set formats.
Security and EncryptionHash Generator
Create MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes of text or files, right in your browser.
Security and Encryption