TOTP Authenticator
Securely generate and verify TOTP codes for 2FA. Support for SHA-1, SHA-256, and SHA-512 with built-in clock drift diagnostics. Keep your accounts private.
Related Utilities
How the TOTP Algorithm Synchronizes Security Tokens
The TOTP (Time-Based One-Time Password) process relies on a shared secret and the current Unix timestamp to generate a synchronized code. At its core, the system calculates a hash based on the current time window, effectively creating a moving target for authentication.
The formula for the TOTP value is defined as:
$$ TOTP = Truncate(HMAC(K, T)) $$
Where $K$ is the secret key in bytes and $T$ is the number of time steps elapsed since the Unix epoch. The $Truncate$ function extracts a specific sequence of digits from the HMAC result to provide the final 6 or 8-digit code. By adjusting the time step, typically set to 30 seconds, you balance security against the likelihood of clock drift.
Comparing TOTP Algorithm Variants and Security Profiles
Selecting the right hashing algorithm is critical for ensuring compatibility with your existing 2FA systems. While SHA-1 remains the industry standard for most legacy applications, current implementations often prefer stronger hashing functions to improve collision resistance.
| Algorithm | Security Profile | Primary Use Case |
|---|---|---|
| SHA-1 | Baseline | Standard legacy and web-based 2FA support |
| SHA-256 | High | Enhanced security for sensitive enterprise tokens |
| SHA-512 | Maximum | Advanced cryptographic requirements and compliance |
Customizing Your TOTP Authenticator Settings
You can modify several variables to test how your time-based one-time password generator behaves under different requirements. The "Authenticator Secret" field accepts a Base32 string, which serves as the root of your unique token generation.
- Digits: Toggle between 6-digit or 8-digit outputs. Most standard 2FA apps default to 6, but high-security environments sometimes use 8 for increased entropy.
- Algorithm: Choose between SHA-1, SHA-256, or SHA-512. Ensure this matches the expected configuration of the service you are protecting.
- Time Step: Adjust the window for token validity. While 30s is the global standard, you can shorten it to 15s for tighter windows or extend it to 60s to accommodate slow manual entry.
Verifying TOTP Codes and Diagnosing Clock Drift
When your 2FA system rejects a code, the culprit is often "clock drift"—a discrepancy between your local system time and the server time. This tool includes a built-in verifier that checks the current token against a range of offsets.
Input your Base32 secret
Paste your shared key into the Authenticator Secret field to initialize the generator.
Enter the token
Type the current 6-digit code provided by your app into the "Token Verifier" input.
Analyze drift
Click "Verify OTP" to see if the tool detects a clock mismatch.
Review diagnostic logs
If the match is successful but not at "Perfect sync," the tool calculates the exact offset (e.g., "30s behind") to help you calibrate your device.
Example Workflow: Troubleshooting a Failed 2FA Login
If you are locked out of an account, you can simulate the validation process to identify if your device clock is lagging. Suppose you have a secret key of JBSWY3DPEHPK3PXP and the server expects a 6-digit code.
Secret: JBSWY3DPEHPK3PXP
Token Input: 284910
Drift Status: Detected
Message: "Drift detected: Your device is 30s behind the client time step."
Generating Backup Recovery Codes for Account Access
If you ever lose access to your authenticator app, backup codes are your last line of defense. The generator creates 8 distinct, high-entropy codes designed to be printed or stored in a secure physical location.
You should always generate these codes immediately upon setting up a new secret. Treat these as you would a physical key; if an attacker gains access to your backup list, they can work around your 2FA protections entirely.
Advanced Usage of the TOTP Token Generator
For developers, the "Show App Setup QR" feature is necessary for testing enrollment flows. It generates an otpauth:// URI that can be scanned by standard mobile authenticator apps.
If you are building an authentication service, this URI acts as the contract between your server and the user's mobile device. Testing different time steps and algorithms here ensures that your backend logic correctly handles edge cases, such as rapid token generation or high-latency network requests during the verification handshake.