What is Base32 Encoding?
Base32 is a binary-to-text encoding scheme that represents binary data using 32 ASCII characters. It's similar to Base64 but uses a smaller alphabet (A-Z and 2-7), making it more suitable for case-insensitive systems and human-readable applications.
Base32 Variants
- Standard Base32 (RFC 4648): Uses A-Z and 2-7 alphabet
- Base32 Hex: Uses 0-9 and A-V alphabet, better for sorting
Common Use Cases
- TOTP/OTP Secrets: Two-factor authentication secret keys
- Torrent Info Hashes: BitTorrent uses Base32 for magnet links
- Git Commit Hashes: Some systems use Base32 for short hashes
- File Systems: Case-insensitive file naming
- QR Codes: Encoding data in QR codes
- DNS Records: DNSSEC uses Base32 encoding
How Base32 Works
Base32 encoding converts binary data into a set of 32 ASCII characters. Every 5 bits of input data is converted into 1 Base32 character. If the input length isn't divisible by 5, padding characters (=) are added to make it so. This results in approximately 60% size increase (compared to 33% for Base64).
Base32 vs Base64
- Base32: 32 characters, case-insensitive, ~60% larger, human-friendly
- Base64: 64 characters, case-sensitive, ~33% larger, more compact
Important Notes
- Base32 is encoding, not encryption - it doesn't provide security
- Encoded data is approximately 60% larger than the original
- Base32 is reversible - anyone can decode it
- Case-insensitive, making it suitable for URLs and file names
- No special characters that need URL encoding
- Always validate and sanitize decoded data for security
Example
Input: Hello, World!
Base32 (Standard): JBSWY3DPEBLW64TMMQQQ====
Base32 (Hex): 91IMOR3F41BMS2JCCGG0====
When to Use Base32
- When case-insensitive encoding is required
- For human-readable identifiers
- In systems that don't support special characters
- For TOTP/2FA secret keys
- When you need URL-safe encoding without escaping