THE BASE64 AND BASE32 ALPHABETS

(From RFC 4648)


The BASE64 Alphabet
Char. Dec. Hex.   Char. Dec. Hex.   Char. Dec. Hex.
A 0 00   W 22 16   s 44 2C
B 1 01   X 23 17   t 45 2D
C 2 02   Y 24 18   u 46 2E
D 3 03   Z 25 19   v 47 2F
E 4 04   a 26 1A   w 48 30
F 5 05   b 27 1B   x 49 31
G 6 06   c 28 1C   y 50 32
H 7 07   d 29 1D   z 51 33
I 8 08   e 30 1E   0 52 34
J 9 09   f 31 1F   1 53 35
K 10 0A   g 32 20   2 54 36
L 11 0B   h 33 21   3 55 37
M 12 0C   i 34 22   4 56 38
N 13 0D   j 35 23   5 57 39
O 14 0E   k 36 24   6 58 3A
P 15 0F   l 37 25   7 59 3B
Q 16 10   m 38 26   8 60 3C
R 17 11   n 39 27   9 61 3D
S 18 12   o 40 28   + 62 3E
T 19 13   p 41 29   / 63 3F
U 20 14   q 42 2A        
V 21 15   r 43 2B   = (pad) (pad)

BASE64 characters are 6 bits in length. They are formed by taking a block of three octets to form a 24-bit string, which is converted into four BASE64 characters.

NOTE: The pad character (=) does not have a binary representation in BASE64; it is inserted into the BASE64 text as a placeholder to maintain 24-bit alignment.

NOTE: In the URL and Filename safe variant, character 62 (0x3E) is replaced with a "-" (minus sign) and character 63 (0x3F) is replaced with a "_" (underscore).

When converting to binary, remember to use only 6 bits (e.g., 0x19 = binary 01 1001).

You can download a BASE64 conversion program here.




The BASE32 Alphabet
Char. Dec. Hex.   Char. Dec. Hex.   Char. Dec. Hex.
A 0 00   M 12 0C   Y 24 18
B 1 01   N 13 0D   Z 25 19
C 2 02   O 14 0E   2 26 1A
D 3 03   P 15 0F   3 27 1B
E 4 04   Q 16 10   4 28 1C
F 5 05   R 17 11   5 29 1D
G 6 06   S 18 12   6 30 1E
H 7 07   T 19 13   7 31 1F
I 8 08   U 20 14        
J 9 09   V 21 15   = (pad) (pad)
K 10 0A   W 22 16        
L 11 0B   X 23 17        

BASE32 characters are 5 bits in length. They are formed by taking a block of five octets to form a 40-bit string, which is converted into eight BASE32 characters.

NOTE: The pad character (=) does not have a binary representation in BASE32; it is inserted into the BASE32 text as a placeholder to maintain 40-bit alignment.

When converting to binary, remember to use only 5 bits (e.g., 0x19 = binary 1 1001).



Examples

BASE64

Convert the following 24-bit string to BASE64:

Convert the following 16-bit string to BASE64 (this could occur only at the end of a file):


BASE32

Convert the following 40-bit string to BASE32:

Convert the following 24-bit string to BASE32:



A useful tool that can convert between various numeric bases, including BASE 32 and BASE64, can be found at http://darkfader.net/toolbox/convert/.