TOTP Generator (2FA Code Tester)
Generate real TOTP codes free online from any base32 secret, following the RFC 6238 standard used by Google Authenticator and Authy. Real HMAC-SHA1 via Web Crypto API.
Real RFC 6238 TOTP via Web Crypto HMAC-SHA1 -- runs entirely in your browser.
How to Use This Tool
Real TOTP Generation, Not a Simulated Countdown
Two-factor authentication codes that refresh every 30 seconds are not random -- they are deterministically calculated from a shared secret and the current time, using HMAC-SHA1 following the RFC 6238 standard. This tool implements that exact algorithm using the Web Crypto API's HMAC support, producing codes that genuinely match what Google Authenticator, Authy, or any RFC 6238-compliant app would generate from the same secret.
This is useful both for understanding how TOTP actually works under the hood and for developers who need to test 2FA integration without reaching for their phone on every debugging iteration.
The Algorithm Behind the Six Digits
The current Unix time, divided into 30-second steps, gets combined with the base32-decoded secret using HMAC-SHA1. A specific truncation step (dynamic truncation, as defined in the RFC) extracts a 6-digit code from the resulting hash. Because both your device and the verifying server perform this exact same calculation independently, no communication is needed between them during code generation -- only the shared secret and synchronized clocks.
Why Clock Synchronization Actually Matters
If a device's clock drifts significantly from real time, the 30-second window it calculates will not match the server's window, and codes will fail to validate even though the secret is correct. This is the most common real-world cause of "my 2FA code keeps failing" -- not a wrong secret, but clock drift, which is why most authenticator implementations allow a small window of tolerance (typically one step before and after).
Frequently Asked Questions
No comments yet
Be the first to share your experience with this tool!