TOTP Generator (2FA)

Generate TOTP 2FA codes — countdown timer with auto-refresh

🔒 Files never leave your browser

Enter a Base32 secret key above to generate TOTP codes

How it works: TOTP uses HMAC-SHA1 with a time-based counter to generate one-time passwords. The code changes every time step. All computation happens in your browser using the Web Crypto API.

How to Use TOTP Generator (2FA)

Enter secret

Enter your base32 secret key.

View code

See the current TOTP code with countdown.

Copy

Copy the code before it expires.

Why Choose AllTools TOTP Generator (2FA)?

  • 100% free, no account needed
  • HMAC-SHA1 algorithm
  • 30-second time step
  • 6 or 8 digit codes
  • Countdown timer
  • No data stored or transmitted

Why Use This Tool

  • All processing happens locally — passwords and keys never leave your device
  • No data stored or transmitted to any server
  • Completely free with no usage limits
  • No account or registration required
  • Uses industry-standard cryptographic algorithms

How Time-Based One-Time Passwords Work

TOTP (Time-Based One-Time Password) generates 6-8 digit codes that change every 30 seconds, providing a second factor of authentication beyond passwords. The algorithm combines a shared secret key (typically 160 bits, encoded as a base32 string like JBSWY3DPEHPK3PXP) with the current Unix timestamp divided by 30 (the time step). This value is passed through HMAC-SHA1, and a portion of the output is converted to a 6-digit number. Because both the server and your authenticator app share the same secret and use the same time reference, they independently compute the same code. Most implementations accept the current code plus one code before and after (a window of ±30 seconds) to account for clock drift between devices. The QR code you scan when setting up 2FA contains a URI like otpauth://totp/Service:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Service — this encodes the secret key, the service name, and the account identifier. This tool generates TOTP codes and secrets locally in your browser using the Web Crypto API, compatible with Google Authenticator, Authy, and 1Password.

Implementing TOTP in Your Application

Adding TOTP-based two-factor authentication to a web application involves several steps. During enrollment: generate a random secret (20-32 bytes), encode it as base32, create an otpauth:// URI, and display it as a QR code. Store the secret securely on your server (encrypted at rest). During verification: the user submits the 6-digit code from their authenticator app, your server generates the expected code using the stored secret, and you compare them. Allow a window of ±1 step (3 codes total) to handle network latency and clock drift. Critical security considerations: always provide backup codes (typically 8-10 single-use codes) in case the user loses their authenticator device. Rate-limit verification attempts (5 attempts per minute) to prevent brute-forcing (a 6-digit code has only 1 million possibilities). Store the user's last validated timestamp to prevent replay attacks — never accept a code that was already used. The RFC 6238 standard defines the algorithm, and libraries exist for every major platform: speakeasy for Node.js, pyotp for Python, rotp for Ruby, and GoogleAuthenticator for PHP.

Related Resources

Frequently Asked Questions

Is this compatible with Google Authenticator?
Yes. Uses the same TOTP algorithm (RFC 6238) with HMAC-SHA1.
Is there a file size limit?
No strict limit. Processing happens in your browser, so capacity depends on your device memory. Most files work smoothly.
Which browsers are supported?
All modern browsers including Chrome, Firefox, Safari, Edge, and Opera on both desktop and mobile.
Can I use this offline?
Yes. Once the page is loaded, the tool works without an internet connection since all processing is local.
Is my data secure?
Yes. Your data never leaves your browser. Nothing is stored on or transmitted to any server.
Does this work on mobile?
Yes. All AllTools tools are fully responsive and work on phones and tablets.

Related Articles

Related Tools

Security

OTP Generator

Generate secure OTPs — numeric, alphanumeric, or hex

Security

Password Generator

Generate passwords, passphrases, and PINs — custom

Dev

Hash Generator MD5/SHA

Generate and compare MD5, SHA-1, SHA-256, SHA-512 hashes instantly

Dev

HMAC Generator

Generate HMAC hashes — SHA-256, SHA-512 with Web Crypto

Security

AES Encrypt/Decrypt

Encrypt and decrypt text with AES-GCM — password-based

Security

QR Code Generator

Generate and customize QR codes with logos and presets