![]() ![]() The reason why need to pad to 24 bits but not 6 bits is because it ensures the decoded data is the same as original data if two Based64 encoded sequences are concatenated and then decoded.įor example, if we encode two string "a.aa" and "a.aa", if we just pad to 6 bits, then the encoded string for "a.aa" would be 011000 010011 101001 100001 011000 010000. In this case, 0 will be padded into the sequence so that it will be exact number of groups of 24 bits(l east common multiple of 6 and 8). Sometimes it's impossible to divide the sequence into exact number of groups of 6 bits. The end result after encoding is "T3ch".īase64 will take byte sequence and divide them to groups of 6 bits. Each 6 bits will be a value between 0 and 63, it will map to one of 64 characters above. ![]() The characters "Ow!" will be converted to three 8 bit byte(0x4F, 0x77, 0x21).Assume there are three characters "Ow!" which are to be Base64 encoded. Since Base64 will use a character to represent 6 bits of data, so the size of Base64 encoded data will be 33% larger than the original data.īelow is a simple example of how Base64 works. These characters include a-z, A-Z, 0-9, +, / and a special purpose character =(The 65th character). These 64 characters are common and can be safely put in a HTTP header. Basics of Base64 Encoding A base64 string is pretty easy to identify: VGhpcyBpcyB3aGF0IGJhc2U2NCBsb29rcyBsaWtlIGluIHRoZSB3aWxkLgo There are 64 characters in the Base64 alphabet, and an encoded string will contain a mixture of uppercase and lowercase letters, numbers, and sometimes an or two (never more than two) at the end. This character will be one of the 64 characters in the Base64 character table. 8 bit to 6 bitīase64 will divide the bytes into groups of 6 bits. It is similar to other encoding schemes such as Uuencode and BinHex but with higher efficiency. These converted characters can safely put in a HTTP header without causing any problem while the peers process the HTTP header.īase64 encoding was invented as part of the MIME content transfer encoding. Base64 encoding can conver arbitrary group of bytes into a sequence of readable ASCII characters. Base64 is a data encoding scheme used in safe data transfer such as HTTP and its extensions. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |