Password & Security

OTP Generator

Generate random one-time passwords for authentication.

OTP

886653

1 code generated

Digits6
Count1

These are random one-time passwords, not time-based (TOTP). Each code is generated independently with cryptographically secure randomness. Digits must be 4–8; count determines how many codes to generate.

What is the OTP Generator?

An OTP generator is a security tool that produces single-use passwords, typically 6-digit codes valid for 30-60 seconds (TOTP) or valid for one login attempt (HOTP). Each code is mathematically derived from a secret key and time or counter value, making it impossible to predict the next code even if a previous one is exposed.

How it works

The generator uses industry-standard algorithms (RFC 4226 for HOTP, RFC 6238 for TOTP) combined with a shared secret key to compute unique codes. For time-based OTPs, the system divides current time into 30-second windows and hashes the result with your secret. For counter-based OTPs, each successful use increments a counter and generates a new code. The last 6-8 digits of the hash become your one-time password.

TOTP = HMAC-SHA1(secret_key, time_counter) mod 10^6; HOTP = HMAC-SHA1(secret_key, counter) mod 10^6

HMAC-SHA1 cryptographically combines your secret key with time (for TOTP) or a counter (for HOTP). The modulo operation (mod 10^6) extracts the final 6 digits. Different implementations may use SHA-256 or SHA-512 for stronger security.

Examples

InputResultNotes
Secret key: JBSWY3DPEBLW64TMMQ5A, Time-based (TOTP)847392 (valid for 27 seconds, then expires)Same secret generates different codes every 30 seconds
Secret key: JBSWY3DPEBLW64TMMQ5A, Counter = 0278532 (changes only on next counter increment)Counter-based OTPs used by some banks; counter increments per use
Gmail 2FA authentication request at 3:45pm562801 (expires at 4:14pm)Most services use TOTP with 30-second windows for user convenience

How to use the OTP Generator

  1. Enter or paste your secret key (usually Base32-encoded from your authenticator app's QR code)
  2. Choose OTP type: TOTP (time-based, recommended) or HOTP (counter-based)
  3. For TOTP, optionally set the time window (default 30 seconds); for HOTP, set starting counter
  4. Click 'Generate' to create your one-time password instantly
  5. Copy the code and use it immediately—most expire within 30-60 seconds
  6. For HOTP, increment the counter and regenerate for the next code

Benefits

  • Adds a second authentication layer even if passwords are stolen
  • Completely free with no registration, email, or tracking required
  • Works offline—no internet needed once the secret key is stored
  • Compatible with major services (Google, GitHub, AWS, Microsoft, Apple, banks)
  • Prevents unauthorized access by generating unpredictable 6-digit codes
  • Supports both time-based and counter-based standards for flexibility

Tips & common mistakes

Common mistakes

  • Storing the secret key in plain text or cloud services; keep it offline in a password manager or secure device
  • Waiting too long to enter the code; most OTPs expire after 30 seconds
  • Sharing the secret key with anyone; compromising it lets others generate valid codes
  • Relying on OTP alone without a strong primary password

Tips

  • Screenshot or print your secret key backup codes when first enabling 2FA—losing them locks you out
  • Use an authenticator app (Google Authenticator, Authy, Microsoft Authenticator) to store secrets securely on your phone
  • Many services allow 5-minute grace periods for clock skew; sync your device time if codes consistently fail
  • For accounts without recovery codes, test 2FA on a non-critical account first

Frequently asked questions

Is this tool safe to use online?

Yes—this is a client-side generator that doesn't transmit your secret key to any server. However, for maximum security with production accounts, store secret keys in a dedicated authenticator app on your phone rather than trusting any online tool with production secrets.

What's the difference between TOTP and HOTP?

TOTP (time-based) generates new codes every 30 seconds based on current time—used by most consumer apps. HOTP (counter-based) generates one code per login attempt—used by some banks and enterprise systems. TOTP is more user-friendly; HOTP is harder to brute-force.

Why does my code keep failing?

Most likely causes: (1) your device clock is out of sync—check the time is correct; (2) you waited longer than 30 seconds to enter the code—OTPs expire quickly; (3) the secret key was entered incorrectly; (4) the service expects a different code length (some use 8 digits instead of 6).

Can two people use the same secret key?

Technically yes, but it's a major security risk—both would generate identical codes, defeating two-factor protection. Each account should have a unique secret key generated by that service.

What if I lose my secret key?

Most services provide recovery codes during setup—use these to regain access and generate a new secret. Store recovery codes in a secure location (printed, password manager, safe). Without recovery codes or backup authentication methods, you may be permanently locked out.

Can OTPs be stolen or replayed?

TOTP codes can't be replayed—each expires within seconds. However, if someone intercepts you entering the code (shoulder surfing, phishing, malware), they could use it immediately. Always verify you're on the official website before entering OTPs.

Related tools

FreeTooz Editorial Team · Last reviewed July 2026

Reviewed for accuracy. Results are estimates for general information and are not professional (medical, financial or legal) advice.