TToolbox
32

Base32 Encode/Decode

Convert between text and Base32

About this tool

Base32 encoding (standardized by IETF RFC 4648 Section 6) is the human-friendly binary-to-text encoding standard powering Two-Factor Authentication secrets (2FA/TOTP), Tor Onion routing addresses, and human-transcribed software license keys. Unlike Base64 which contains case-sensitive collisions and symbols (`+`, `/`), Base32 uses a clean 32-character alphabet (A–Z and digits 2–7). It explicitly excludes visually ambiguous characters: 0 (confused with O), 1 (confused with I/l), and 8. This tool provides bidirectional Base32 encoding and decoding locally.

How to Use This Tool (Step-by-Step)

1

Enter Plaintext or Base32 String

Input your plain text message or paste an existing Base32 secret key (like a 2FA TOTP seed) into the editor pane.

2

Select Encoding & Padding Options

Select your direction: Text to Base32 or Base32 to Text. Toggle RFC 4648 trailing padding `=` characters on or off.

3

Copy Sanitized Base32 Output

The sanitized Base32 output renders immediately in real time. Copy the text block directly into your authenticator app or codebase.

RFC 4648 Alphabet Compliance

Rigorously adopts the official `A-Z` and `2-7` mapping table, ensuring 100% interoperability with Google Authenticator and 1Password.

Human Transcription Friendly

Eliminates visual ambiguity (0/O, 1/I/l), enabling human voice readouts and casual keyboard entry without transcription failures.

100% Client-Side Air-Gapped

All 5-bit packing routines run exclusively in local browser memory. Critical 2FA authentication seeds are never logged.

2FA Secret Hygiene & Base32 Best Practices

  • •Strip spaces from 2FA seeds: Portals group seeds visually (`JBSW Y3DP`). Strip all spaces before feeding seeds into authentication software.
  • •Why Tor uses Base32 for .onion addresses: DNS is historically case-insensitive; Base32's single-case alphabet maps flawlessly into domain hostnames.
  • •Payload expansion rate (+60%): Base32 expands byte volumes by 60%. Reserve it for security tokens and credentials rather than large multimedia.

Code & Transformation Examples

Base32 Encoding Output Benchmark

Original Plaintext
• "Hello"
• "foobar"
• "2FA-Secret"
Base32 Encoded String
• "Hello"      -> JBSWY3DP
• "foobar"     -> MZXW6YTBOI====== (末尾带等号填充)
• "2FA-Secret" -> GI3DGMZTGVSXGZJT

* Authenticator QR codes store shared secrets directly inside `secret=JBSWY3DP` Base32-formatted query parameters.

JavaScript Base32 5-bit Bitwise Implementation Snippet

Base32 Encoder Implementation
const RFC4648_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';

function encodeBase32(bytes) {
  let bits = 0, value = 0, output = '';
  for (let i = 0; i < bytes.length; i++) {
    value = (value << 8) | bytes[i];
    bits += 8;
    while (bits >= 5) {
      output += RFC4648_ALPHABET[(value >>> (bits - 5)) & 31];
      bits -= 5;
    }
  }
  if (bits > 0) {
    output += RFC4648_ALPHABET[(value << (5 - bits)) & 31];
  }
  while (output.length % 8 !== 0) output += '=';
  return output;
}
Mathematical Mechanics
Base64 每次取 6 位二进制(2^6=64),而 Base32 每次取 5 位二进制(2^5=32)。5 个字节(40 bit)刚好能整除转化为 8 个 Base32 字符!

* The 40-bit least common multiple yields up to 6 trailing `=` padding markers for incomplete final chunks.

Frequently Asked Questions

Q: Why does Base32 use digits 2 through 7 instead of 0 through 9?

A: 26 letters + 6 digits = 32. Digits 0, 1, and 8 were deliberately eliminated to prevent visual confusion with letters O, I, and B.

Q: Can lowercase characters be decoded successfully?

A: Yes. An automated pre-sanitizer converts all lowercase letters to uppercase and strips random whitespace prior to parsing.

Q: Can Base32 strings be decoded if trailing `=` padding is missing?

A: Yes. Trailing padding is an alignment formality. The streaming bitwise decoder reconstructs original bytes even if padding is absent.

Related Tools

All processing happens locally in your browser. Your data is never uploaded to a server.
/