Base64 Transfer Encoding for MIME (rfc 2045)
Base64 is a data encoding scheme whereby binary-encoded data is converted to printable ASCII characters. It is defined as a MIME content transfer encoding for use in internet e-mail. The characters used are A–Z, a–z and 0–9 with the "+" and "/" symbols. The "=" symbol as a special suffix code.
Full specifications for base64 are contained in RFC 1421 and RFC 2045 - MIME (Multipurpose Internet Mail Extensions). The scheme works on 8 bit data. The resultant base64-encoded data has a length that is greater than the original length by the ratio 4:3.
Three bytes are concatenated, then split to form 4 groups of 6-bits each; and each 6-bits gets translated to an encoded printable ASCII character, via a table lookup. An encoded string is therefore longer than the original by about 1/3. The "=" character is used to pad the end out to an even multiple of four.