TOTP Secret Generator (2FA)

Base32 shared secrets for TOTP two-factor authentication, plus the otpauth:// URI.

Copy the result before closing this tab.

Create a 20-byte shared secret encoded as base32 for authenticator enrollment. The provisioning URI also contains the secret. Your server still needs to verify codes and protect enrollment.

Why base32, of all things

TOTP secrets are printed in base32 for one reason: humans have to type them. RFC 4648's base32 alphabet is uppercase letters and the digits 2 through 7 — it deliberately omits 0, 1, 8 and 9 precisely because they are the digits people confuse with O, I and B. It is less dense than base64, which nobody cares about, and it survives being read off a screen and typed into a phone, which everybody does. The QR code you usually scan is simply this same string wrapped in the otpauth:// URI printed above.

How long should it be?

20 bytes (160 bits, 32 base32 characters) is the default. RFC 4226 §4 requires at least 128 bits and recommends 160 bits. Use a length and hash algorithm supported by your authenticator and verification library.

What this secret does and does not protect

TOTP is a shared secret: the server holds the same value your authenticator app does. That is its structural weakness — a server breach exposes every user's second factor, and it is why TOTP does not stop a convincing phishing page, which simply asks you for the current code and replays it within its 30-second window. TOTP is a large improvement over a password alone and a poor substitute for a passkey or a hardware key, which are bound to the origin and cannot be relayed. Generate the secret once, let the user scan it, store it encrypted, and issue recovery codes — because a lost phone is far more common than an attacker.

FAQ

How long should a TOTP secret be?

RFC 4226 requires at least 128 bits and recommends 160 bits. This tool defaults to 20 random bytes (160 bits), encoded as 32 base32 characters. Check your authenticator and server library for supported lengths.

Is the provisioning URI secret?

Yes. The otpauth URI contains the shared secret. Treat it like the secret itself and do not put it in logs, public screenshots or analytics.

Does TOTP prevent phishing?

A phishing site can relay a current TOTP code. TOTP improves on passwords alone but is not phishing-resistant. Consider passkeys where supported.

How generation works

About & privacy

Generated on your device

Web Crypto provides the randomness. Generation works offline after the page has loaded.

No accounts, no saved values

No account or cookies. Self-hosted, cookieless analytics counts page views, outgoing link clicks and which generator type is copied — never a generated value, which stays in this tab until you copy it.

Browser and device security

A compromised browser or device can expose values. For production private keys, use a trusted local tool.

Other generators

All generators ↗