Base32
Last updated
Was this helpful?
Last updated
Was this helpful?
Base32 is a method of encoding binary data into a text format using a set of 32 ASCII characters. This encoding is particularly useful for cases where data integrity and compatibility with text-based systems are important. Base32 is often used in applications like QR codes, DNS records, and secret keys in two-factor authentication systems.
Character Set: Base32 uses a set of 32 characters, typically the uppercase letters A-Z and the digits 2-7. This avoids confusion between similar-looking characters such as 'I' and '1' or 'O' and '0'.
Padding: Base32 encoded output is often padded with '=' characters to make the final output length a multiple of 8.
Efficiency: Base32 is less space-efficient than Base64 but is more human-readable and suitable for use in systems where case-insensitivity or URL safety is required.
Grouping: The binary data is divided into groups of 5 bits (2^5 = 32).
Mapping: Each 5-bit group is mapped to a corresponding Base32 character.
Padding: If the final group has fewer than 5 bits, it is padded with zero bits, and the resulting Base32 string is padded with '=' to make its length a multiple of 8.
Remove Padding: Remove any '=' padding characters.
Grouping: Convert each Base32 character back to its corresponding 5-bit binary representation.
Reconstruct: Combine the 5-bit groups into the original binary data.
Let's encode the string "Hello" using Base32.
Binary Representation:
H: 01001000
e: 01100101
l: 01101100
l: 01101100
o: 01101111
Combined binary: 0100100001100101011011000110110001101111
Group into 5-bit Chunks:
01001, 00001, 10010, 10110, 11000, 11011, 00011, 01111
Map to Base32 Characters:
01001 -> J
00001 -> B
10010 -> S
10110 -> W
11000 -> Y
11011 -> 3
00011 -> D
01111 -> P
Result: The Base32 encoded string is "JBSWY3DP".
QR Codes: Encoding data in a format that is easily readable and less error-prone.
DNS Records: Encoding binary data in DNS records where only certain characters are allowed.
Secret Keys: Sharing secret keys in two-factor authentication systems, as it avoids issues with case sensitivity.
File Names: Creating URL-safe file names that can be easily transmitted over the web without encoding issues.