Xerobit

TOTP Secret Generator: Base32 Keys and otpauth URIs

This totp secret generator creates a random Base32 key (RFC 4648, no padding) and the matching otpauth URI for authenticator apps. Pick 16, 20 or 32 characters, enter an issuer and account, and generate. It runs in your browser.

Result

  • Secret
    OFF2RNQKERBVE6H5NKUKBNAOMVVUYEGZ

    Base32 (RFC 4648), no padding

  • otpauth URI
    otpauth://totp/MyApp:user%40example.com?secret=OFF2RNQKERBVE6H5NKUKBNAOMVVUYEGZ&issuer=MyApp&algorithm=SHA1&digits=6&period=30
  • Entropy
    160 bits

    32 characters x 5 bits

How to use the totp secret generator

  1. Choose the secret length: 16 characters provides 80 bits of entropy, 20 gives 100 bits, and 32 gives 160 bits.
  2. Enter the issuer (your service name) and account (username or email) to label the entry in authenticator apps.
  3. Click Generate to produce a new random Base32 secret.
  4. Copy the Base32 secret to enter it manually, or use the otpauth URI to create a QR code for scanning.

How Base32 secrets work

TOTP (Time-based One-Time Password) relies on a shared secret between the server and the authenticator application. This secret is encoded in Base32, which uses the letters A through Z and the digits 2 through 7. Base32 is chosen because it leaves out the digits 0, 1, 8 and 9, so an O or an I in a secret is always the letter and never a zero or a one. That reduces transcription errors when typing a secret by hand.

Each Base32 character represents exactly 5 bits of data. Therefore, a 16-character secret holds 80 bits of entropy, a 20-character secret holds 100 bits, and a 32-character secret holds 160 bits. RFC 4226 requires a shared secret of at least 128 bits and recommends 160 bits, which only the 32-character option meets. The 16 and 20 character options are offered because some authenticator apps and older systems still use 80 and 100 bit secrets.

The otpauth URI format

The otpauth URI is a standardized string that tells an authenticator app everything it needs to set up an account. Its structure follows this pattern:

otpauth://totp/ISSUER:ACCOUNT?secret=BASE32SECRET&issuer=ISSUER

The path contains the issuer and account separated by a colon. The query parameters include the Base32 secret and the issuer again. When you feed this URI into a tool like the QR code generator, the resulting QR code can be scanned directly by apps such as Google Authenticator, Authy or Aegis. If you need to verify the codes produced by your new secret, you can use a totp generator to compute the six-digit values.

Secret length comparison

Different lengths offer different levels of brute-force resistance. Here is how the common sizes compare:

CharactersEntropy (bits)Possible combinationsTypical use
1680280Compatibility with older apps; below the RFC 4226 minimum
201002100Compatibility only; below the RFC 4226 minimum
321602160Recommended: meets the RFC 4226 minimum and recommendation

For new systems choose 32 characters (160 bits), the length RFC 4226 recommends. The shorter options exist so you can match an authenticator app or server that already expects 16 or 20 characters.

Storing and handling secrets safely

A TOTP secret is equivalent to a password. Anyone who obtains it can generate valid authentication codes. Store secrets securely on the server side, ideally encrypted at rest. Never log them in plain text or expose them in client-side JavaScript after initial setup.

When provisioning a user, display the secret or its QR code only once during enrollment. After the user confirms their authenticator is working, discard the plain-text representation from memory. If you are building a system that issues these secrets, consider pairing them with other cryptographic tools like an HMAC-SHA256 generator for signing related payloads.

Common mistakes to avoid

Several pitfalls cause TOTP setups to fail silently. First, ensure the Base32 string does not contain padding equals signs if your library expects raw input. Second, the issuer parameter in the URI must match the issuer in the path prefix; mismatches cause some apps to display blank labels. Third, URL-encode special characters in the account name or issuer. Spaces must become %20 (not +), and symbols like & or + must be percent-encoded to prevent breaking the URI parser. This tool also encodes @, which apps decode correctly.

Finally, remember that the server clock and the authenticator clock must be loosely synchronized. Most implementations allow a window of one time step (30 seconds) in either direction to account for minor drift.

Worked examples

ExampleInputResult
Default 32 charactersSecret length: 32; Issuer: MyApp; Account: user@example.comSecret: VJHGO2HVL2SWW2JFILESIATWNSBEZJQB; otpauth URI: otpauth://totp/MyApp:user%40example.com?secret=VJHGO2HVL2SWW2JFILESIATWNSBEZJQB&issuer=MyApp&algorithm=SHA1&digits=6&period=30; Entropy: 160 bits
Issuer with a spaceSecret length: 16; Issuer: Acme Corp; Account: john+test@example.comSecret: JHNWKGONISLNSP5A; otpauth URI: otpauth://totp/Acme%20Corp:john%2Btest%40example.com?secret=JHNWKGONISLNSP5A&issuer=Acme%20Corp&algorithm=SHA1&digits=6&period=30; Entropy: 80 bits
100-bit secretSecret length: 20; Issuer: Example; Account: adminSecret: 4SLYR7HMSYHW7MO4HMWB; otpauth URI: otpauth://totp/Example:admin?secret=4SLYR7HMSYHW7MO4HMWB&issuer=Example&algorithm=SHA1&digits=6&period=30; Entropy: 100 bits

FAQ

What is a TOTP secret?

A TOTP secret is a shared cryptographic key encoded in Base32. Both the server and the authenticator app use it along with the current time to independently compute matching six-digit codes.

Why is Base32 used instead of Base64?

Base32 uses a case-insensitive alphabet of A to Z and 2 to 7. With no 0, 1, 8 or 9 in it, a secret read aloud or typed from a screen is much less error-prone than Base64, which mixes upper and lower case and includes + and /.

How long should my secret be?

Use 32 characters, which is 160 bits and the length RFC 4226 recommends (it requires at least 128 bits). The 20-character (100 bit) and 16-character (80 bit) options are for matching older apps or servers that already use those sizes.

Can I reuse the same secret for multiple services?

No. Each account on each service should have a unique secret. Reusing a secret means compromising one service compromises all others using that same key.

Is this totp secret generator secure?

Yes. It uses the Web Crypto API to generate random bytes directly in your browser. No data is sent over the network, and the secret never leaves your device.

What do I do with the otpauth URI?

You can convert the URI into a QR code using a QR code tool. Scanning that code with an authenticator app automatically configures the account without typing the secret manually.