Base64 is a binary data encoding, using only 64 ASCII characters in its output. This makes it possible to embed or transmit Base64-encoded data in many places where binary data isn't an option. The online base64 encoder tool follows these steps:
|
|
Input Conversion – The input is first converted to a binary byte stream. Either by converting the text to UTF-8 or by using the raw bytes from the text. |
|
|
Binary Encoding – Each 6 bits of input data is then mapped to one of the 64 Base64 characters (A-Za-z0-9+/). This means that 3 bytes of input (3 * 8 = 24 bits) will result in 4 bytes of output (4 * 6 = 24 bits), a size increase of 33%. |
|
|
Padding – If the input stream has a length that is not evenly divisible by 3, the output is padded with one or two "=" characters at the end. These additional bits are removed when decoding. |
|
|
Formatting – As an optional last step, the output ASCII text is split into lines of 64 characters. This will avoid additional line breaks in most email programs and results in a more readable and recognizable output. |
The base64 decoder tool provides the reverse process, by removing any non-base64 character from the input and processing the remaining characters accordingly.
See also the Wikipedia articles on Base64 or data URI:s for more info.