2FA Code Generator
Generate time-based one-time passwords (TOTP) for two-factor authentication using a Base32 secret key. Works with Google Authenticator, Authy, and Microsoft Authenticator. Configurable digits (6-8), algorithm (SHA-1/SHA-256/SHA-512), and time step (30-90s). 100% client-side, no data leaves your browser.
How to Use This Tool
What Is 2FA Code Generator?
A time-based one-time password (TOTP) is a temporary, single-use code that changes every 30 seconds (or a set interval). It adds a strong layer of security beyond just a password, preventing unauthorized access even if your login credentials are stolen.
This 2FA Code Generator lets you generate those codes directly in your browser using your Base32 secret key. Because everything runs client-side, your key never touches a server—your privacy is fully protected.
Whether you use Google Authenticator, Authy, or Microsoft Authenticator, this tool works the same way. It’s perfect for quickly retrieving codes when you don’t have your phone handy or want a second device to generate them.
Formula
- K is your Base32-decoded secret key (a random byte string). - T0 is the start time (usually 0), and X is the time step (default 30 seconds). - The HOTP function applies HMAC-SHA1 to the key and the counter T, then truncates the result to produce a 6–8 digit code. In plain terms: the tool takes the current time, divides it into 30-second windows, combines that window number with your secret key using a hashing algorithm, and extracts a short numeric code that only you can generate.