
The first three bytes will be group together. Now let’s see another example in which the input string has 5 characters bits representation of the above string will be a b c dĠ1100001 01100010 01000000 01100011 01100100 And since we added 4 extra zero, Hence two = at the end. Below will the mapping 24Įach two extra zero is represented by = character. Use the above numbers to index into the above table. The last bytes will be padded with 4 extra zero to make the overall bits divisible by 6. Let’s say the input string has 4 characters bits representation of the above string will be a b c What if the input string is not in multiples of 3? In this case padding character = will come in the picture So the base64 encoded string will be YWJA Use the above numbers to index into the base64 table. The numeric representation of the above bits is 24 22 9 0 These total 24 bits will be grouped into 4 groups of 6 bits each 011000 010110 001001 000000 Let’s say we have the below string bits representation of the above string will be a b 01100010 01000000 Value Encoding Value Encoding Value Encoding Value Encoding Then each 6-bit group will be indexed in the below table to get the mapped character. Now it will divide these 24 bits into four parts of 6 bits each. It will start scanning from left to right, and then it will select the first 3 bytes of data representing 3 characters. How Base64 encoding/decoding worksīase64 encoding will translate every 3 bytes of data into 4 encoded characters. So essentially encoding is meant for compatibility and not for encryption.
Base64 encoding with 64 length basic password#
In this case, we encrypt the password so that any unintended person cannot read it. So in the case of encryption, the data can only be reversed by someone who possesses the key.įor eg sending a password over the network. It is always protected by a key and it meant to be decrypted by anyone who knows the key. Your binary data cannot be transferred through such a medium as there are chances of data being getting corrupted.Įncoding doesn’t provide any kind of security, instead, it is only meant for compatibility across different media which understand different formatĮncryption is meant for confidentiality.

Some of the transfer media only understand textual data or a certain number of characters. So anyone knowing the algorithm can simply reverse and get the original data. There is no secret key involved and is reversible. Encoding is just an algorithm that is publicly available. What’s the difference between encoding and encryption?Įncoding means transforming data into another format so that it can be properly consumed by a system that only understands the converted format. Note that it is encoding and not encryption. These 64 characters are present in most character sets so you can be reasonably confident that your data will the other end without any corruption. It is mostly needed for legacy systems that work with only ASCII data.īut why 64 characters and not more. As it is guaranteed that data won’t be corrupted. So base64 was meant for media that does not support binary data and which work with only textual characters. In other words, these media are not 8 bit clean and are only meant to handle textual data. The problem with binary data is that some characters in the binary data might have special meaning in some media. They are only meant for streaming text and as such these protocols might interpret your binary data as control characters or some special characters in the binary data may be interpreted differently. Some media such as email support only textual data. Video and audio are binary data and when binary data is transferred over the internet there are good chances of it being corrupt. Later on, the email also started supporting attachments which including video and audio. Initially, when the mailing system was started it was only text which was transferred through email. Let’s talk about history to know why base64 was needed. A base 64 encoding will look like as below OWRjNGJjMDY5MzVmNGViMGExZTdkMzNjOGMwZTI3ZWI= Why Base64 encoding is needed So Base64 encoding of data is done to make sure that the data remains intact without any modification through this media. These printable characters areīase64 encoding is used for transferring data over a medium that doesn’t handle binary data correctly. So it is a way of representing binary data using only printable characters.

Base64 encoding with 64 length basic plus#
But it uses only 64 characters and plus one padding character which are present in the most character set. Base64 is the encoding of binary data into ASCII text.


Base64 is also known as Base64 Content-Transfer-Encoding.
