Base64 describes a method in which binary data is converted into a string consisting of only 64 different ASCII characters.
Three 8-bit bytes (i.e. a total of 24 bits) are divided into four 6-bit groups. Each of these groups corresponds to a number between 0 and 63. These numbers are converted to a conversion table into “printable ASCII characters”.
If the total number of input bytes is not divisible by three, the text to be encoded is padded at the end with fill bytes consisting of zero bits, resulting in a number of bytes divisible by three. To tell the decoder how many padding bytes have been added, the 6-bit blocks that have been completely created from padding bytes are encoded with =. Thus, no, one, or two = characters may appear at the end of a Base64-encoded file. In other words, as many = characters are appended as fill bytes have been appended.