Base64 encoding is a way of representing binary data in a text-only form. It is commonly used in LDAP Data Interchange Format for values containing non-ASCII characters, or for values that could otherwise be ambiguous (e.g., values that begin or end with spaces). It is also frequently used to encode certificate contents or the output of message digests like MD5 or SHA. The base64 encoding is described in section 5.2 of RFC 1341
The basic principle of base64 encoding is that it defines a 64-byte alphabet containing the following characters in the given order:
Each of those characters is assigned a numeric value between 0 and 63 based on its position in the list (i.e., "A" is 0, "B" is 1, "C" is 2, ... "+" is 62, and "/" is 63). A value is broken up into six-bit segments, and each of those six bits is converted into a numeric value between 0 and 63 and replaced with the specified character from the alphabet given above. This means that every three bytes of a binary value is converted into four characters from the base64 alphabet. If the length of the binary value is not a multiple of three bytes, then it is zero-padded and either one or two equal signs are appended to the base64-encoded value.