Toolical © 2026

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.

Result
Please check your inputs.

📖 How to Use This Tool

Locate your Base32 secret key from your 2FA setup page (usually a 16–32 character string of letters A-Z and digits 2-7).
Paste or type the secret key into the input field on the 2FA Code Generator.
Optionally adjust the time step (default is 30 seconds) if your authenticator app uses a different interval.
Click the Generate button or wait for the automatic countdown—the current one-time password (6–8 digits) will appear.
Copy the generated code and enter it in the service you are authenticating with before it expires (watch the timer).

📝 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

The tool uses the standard TOTP formula: TOTP = HOTP(K, T), where T = floor((current Unix time in seconds - T0) / X).

- 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.

💡 Tips for Best Results

🔐 Never share your Base32 secret key with anyone—anyone with it can generate your 2FA codes.
⏱ If codes are not working, check that your device clock is synchronized to internet time (enable automatic time sync).
📱 Generate a backup of your secret key (e.g., print or copy to a secure vault) in case you lose access to your authenticator app.
🔄 Use this tool completely offline—it works without internet, making it ideal for air-gapped devices.

Frequently Asked Questions

What is a Base32 secret key?
A Base32 secret key is a string using only letters A–Z and digits 2–7, encoding a random secret. Services provide this key when you enable two-factor authentication so you can import it into any TOTP-compatible app.
Can I use this tool with Google Authenticator, Authy, or Microsoft Authenticator?
Yes, absolutely. All three apps use the same TOTP standard with Base32 keys. Simply copy the same secret key into this generator and it will produce identical codes that those apps would show.
Is my secret key safe when using this online tool?
Yes, your secret key never leaves your browser. All calculations are done locally in JavaScript with no server communication. The tool is 100% client-side, so your data stays private on your device.

🔗 Related Tools