Base64 Decoder and Encoder Tool

Base 64 Converter :

As the name suggests, Base 64 is a way of viewing data in base 64. Rather than counting from 1 to 10 or 16, we count from 1 to 64 with an alphabet of 64 characters. A 65th character is used to terminate Base 64 sequences, and that's the "=" sign. The Base 64 alphabet includes lowercase letters, uppercase letters, numbers, as well as the "+" and "/" signs, making a total of 64 different characters. Base 64 uses a binary representation with 6 bits, allowing for 64 different states.

To convert text to base64, we first separate the text into "pieces" of 24 bits (3 bytes). Once these pieces are created, we assign a base 64 value to every 6 bits. For example, for the word "md5":

ASCII: m d 5
Binary: |011011 01|0110 0100|00 110101|
Base 64: b W Q 1

So, the Base 64 correspondence to the word "md5" is "bWQ1".

Now, what do we do when the number of bits is not exactly a multiple of 6 when we created the 24-bit pieces? Well, we fill in the missing bits with "0" bits. For example, for "sha1," we correctly encrypt the first three letters "sha," then there is one byte left, which is not a multiple of 6. So, we add 4 "0" bits (8 + 4 = 6*2 = 12 bits). Then we add two "=" signs to add the two missing characters to reach 24 bits.

This means you can tell by looking at a Base 64 string whether the last piece contained 1, 2, or 3 bytes. If there were 3 bytes left, it is indeed a multiple of 6, so no need to add "=" at the end. If there is only one byte left, as mentioned earlier, you will need to add two "=" signs. If there are two bytes left, you will need to add one "=" sign.

Update cookies preferences