Base32 vs Base64: Definitions, Use Cases, Character Sets

Base32 vs Base64 Comparison: Definitions, Use Cases, Character Sets

This blog post compares Base32 and Base64, delving into their definitions, use cases, and character sets. Discover their strengths, weaknesses, and the best times to use them in your applications. Whether you’re new to data encoding or need encoding guidance, this article offers valuable insights for making informed choices.

Base32

Base32 is essentially a binary-to-text encoding method that makes it possible to represent binary data in a logically comprehensible manner. To do this, it uses a set of 32 characters. As opposed to raw binary data, which may contain odd or unprintable characters that could be problematic for storage or transmission.

The key to Base32 lies in its character set. This encoding scheme uses a specific set of 32 characters, which include uppercase letters A through Z and the digits 2 through 7. This character set was designed with careful consideration to avoid ambiguity and ensure that the encoded data can be accurately decoded.

Here are the 32 characters used in Base32:

BinaryDecimalBase32
000000A
000011B
000102C
000113D
001004E
001015F
001106G
001117H
010008I
010019J
0101010K
0101111L
0110012M
0110113N
0111014O
0111115P
1000016Q
1000117R
1001018S
1001119T
1010020U
1010121V
1011022W
1011123X
1100024Y
1100125Z
11010262
11011273
11100284
11101295
11110306
11111317

Encoding data with Base32 is a straightforward process. You take your binary data and convert it into a series of 5-bit chunks. Each 5-bit chunk is then mapped to the corresponding character from the Base32 character set. This results in a text string that is safe for transmission and storage.

Decoding Base32 is the process of converting Base32-encoded text back into its original binary form, using the character set as a reference.

Base64

Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format. It is commonly used to encode binary data so that it can be safely transmitted or stored as text, making it suitable for a wide range of applications, including email attachments, data transmission over text-based protocols, and storing binary data in text files such as XML and JSON.

In Base64 encoding, each group of three bytes (24 bits) of binary data is represented by four ASCII characters.

The encoding process involves the following steps:

  1. Divide the binary data into 6-bit chunks.
  2. Map each 6-bit chunk to its corresponding ASCII character based on a predefined mapping table.
  3. If the binary data does not have a length that is a multiple of 3, padding characters (usually one or two equal signs, ‘=’) are added to make the output length a multiple of 4.

Base64 encoding uses a specific set of 64 characters, which typically include A-Z, a-z, 0-9, and two additional characters such as ‘+’, and ‘/’. The choice of these characters can vary slightly in different implementations, and some variations exist, such as URL-safe Base64, which uses different characters to avoid conflicts with URLs.

Here is the comprehensive Base64 character table:

CharacterBinaryDecimal
A0000000
B0000011
C0000102
D0000113
E0001004
F0001015
G0001106
H0001117
I0010008
J0010019
K00101010
L00101111
M00110012
N00110113
O00111014
P00111115
Q01000016
R01000117
S01001018
T01001119
U01010020
V01010121
W01011022
X01011123
Y01100024
Z01100125
a01101026
b01101127
c01110028
d01110129
e01111030
f01111131
g10000032
h10000133
i10001034
j10001135
k10010036
l10010137
m10011038
n10011139
o10100040
p10100141
q10101042
r10101143
s10110044
t10110145
u10111046
v10111147
w11000048
x11000149
y11001050
z11001151
011010052
111010153
211011054
311011155
411100056
511100157
611101058
711101159
811110060
911110161
+11111062
/11111163

Comparison

Base32 and Base64 are both encoding schemes used to represent binary data in a human-readable format. Base64 is more commonly used, while Base32 is often used in specific applications, such as URLs, where certain characters have special meanings or restrictions. The choice between them depends on the specific requirements of your application.

Compare Base32 vs Base64 - Infographic

The table below compares Base32 and Base64 in the most important aspects.

Base32Base64
Character SetA-Z, 2-7A-Z, a-z, 0-9, +, /
Number of Characters3264
Padding Character==
Encoding AlgorithmGroups data into 5-bit chunksGroups data into 6-bit chunks
Common Use CasesUsed in file and folder names in URL paths, geocaching, and some cryptographic applicationsCommonly used for encoding binary data in email attachments, JSON, and other data transmission formats
URL SafeYesNo
Case SensitivityCase-insensitiveCase-sensitive
EfficiencyLess efficient for binary dataMore efficient for binary data
Example“Base32Encode.com” -> “IJQXGZJTGJCW4Y3PMRSS4Y3PNU======”“Base32Encode.com” -> “QmFzZTMyRW5jb2RlLmNvbQ==”