Base 64 converter
Base64 is a method of encoding information using 64 characters. It allows binary data to be represented in ASCII text, using a set of 64 printable characters. This method is commonly used to transmit data over channels that cannot handle binary data, such as emails and web pages.
The digits of Base64
The digits of Base64 consist of 4 groups:
• Uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ (values 0 to 25)
• Lowercase letters abcdefghijklmnopqrstuvwxyz (values 26 to 51)
• Digits 0123456789 (values 52 to 61)
• Special symbols +/ (values 62 and 63):
The conversion table of Base64 digits to decimal and binary is as follows:
Uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ
A | B | C | D | E | F | G | H | I | J | K | L | M |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
000000 | 000001 | 000010 | 000011 | 000100 | 000101 | 000110 | 000111 | 001000 | 001001 | 001010 | 001011 | 001100 |
N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
001101 | 001110 | 001111 | 010000 | 010001 | 010010 | 010011 | 010100 | 010101 | 010110 | 010111 | 011000 | 011001 |
Lowercase letters abcdefghijklmnopqrstuvwxyz
a | b | c | d | e | f | g | h | i | j | k | l | m |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
011010 | 011011 | 011100 | 011101 | 011110 | 011111 | 100000 | 100001 | 100010 | 100011 | 100100 | 100101 | 100110 |
n | o | p | q | r | s | t | u | v | w | x | y | z |
39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
100111 | 101000 | 101001 | 101010 | 101011 | 101100 | 101101 | 101110 | 101111 | 110000 | 110001 | 110010 | 110011 |
Digits 0123456789
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
110100 | 110101 | 110110 | 110111 | 111000 | 111001 | 111010 | 111011 | 111100 | 111101 |
Symbols + and /
+ | / |
62 | 63 |
111110 | 111111 |
In addition to this alphabet, the symbol = is used as a padding character.
Example of encoding a text in Base64
Let's encode the word "Film" in Base64 step by step.
Step 1
Convert the word "Film" to its ASCII binary representation:
F | i | l | m | |
Decimal values | 70 | 105 | 108 | 109 |
Binary values | 01000110 | 01101001 | 01101100 | 01101101 |
Step 2
Join the binary values:
01000110 01101001 01101100 01101101
• Group the ASCII binary representation into blocks of 6 bits:
010001 100110 100101 101100 011011 01
Step 3
Add zeros to the right of the last block to make its length equal to 6 bits:
010001 100110 100101 101100 011011 010000
Step 4
Convert each 6-bit block to decimal:
010001 -> 17
100110 -> 38
100101 -> 37
101100 -> 44
011011 -> 27
010000 -> 16
A base2 to base10 converter is here.
Step 5
Base64 encoding using the Base64 correspondence table above:
17 -> R
38 -> m
37 -> l
44 -> k
27 -> b
16 -> Q
Step 6
Concatenate the encoded values and add the padding character = to make the number of characters a multiple of 4 (here 8 characters)(*):
RmlsbQ==
Thus, "Film" in Base64 is written as "RmlsbQ==".
(*) Base64 encoding is done in packets of 4 x 6 bits because 6 bits can exactly represent 64 different values (2^6 = 64). Thus, each group of 6 bits can be represented by a character from the Base64 table. By grouping the original data into packets of 3 bytes (i.e., 3 x 8 = 24 bits), we get 4 groups of 6 bits, each of which can be represented by a Base64 character. This allows binary data to be converted to a more compact and portable textual representation, while avoiding compatibility issues with systems that may not handle certain ASCII characters.
See also
Conversion to base n
Cryptographic Calculators