Base64 is a coding method used to convert binary data into plain text for transfer across computer networks. It was developed to transmit non-text characters in email messages and is described in the MIME standard. Base64 converts groups of three bytes into four ASCII characters, but padding is needed for sequences of bytes that are not divisible by three. It is used in various applications, including creating URLs and including binary data in XML documents.
Base64 is a method of converting arbitrary binary data, data consisting of more than just text characters, into a plain text message that can then be transferred across a computer network. It’s what’s called coding. While the output of a base64-encoded message isn’t something that a human can easily understand, it is still composed of the common 64 characters of the English language, from which the name derives, with an additional 65th character used for special purposes.
The idea behind base64 arose when the need arose to get more than just text characters through network communications such as email. The first email messages began as characters encoded in the American Standard Code for Information Interchange (ASCII), the encoding method used in computers to represent characters from the English language alphabet as text on displays or printers. As the additional binary information needed to pass, new coding schemes were developed.
The base64 encoding method was first described in what is known as the Multipurpose Internet Mail Extensions (MIME) standard. The methods defined by the MIME standard by which other non-ASCII-encoded characters, such as alphabets used by languages other than English, as well as other arbitrary binary data, can be encoded into ASCII sequences and transmitted via e-mail messages. Of the two main encoding mediums described by the MIME standard, base64 shares the role with another known as quoted-printable. While the quoted printable method is able to extend ASCII a bit beyond its limited 94 printable characters, base64 can take any sequence of bytes and convert it to an ASCII sequence.
Base64 has to take strings of data that would otherwise not meet the ASCII standard and convert them to ASCII. To do this, the encoding method is to collect the data in groups of three bytes and convert them into four numbers representing the corresponding ASCII characters. Since a byte is eight bits, where each bit is represented by ones or zeros, three bytes are connected end-to-end and the entire sequence goes into a 24-bit buffer. The 24 ones and zeros are then split into four groups of six bits, each of which is then assigned numbers that correspond to an ASCII character.
Since base64 is capable of encoding any binary data, any sequence of bytes can go through the process. There is a problem, however, in those cases where the number of bytes for encoding is not divisible by three so that the bits can fit into the buffer. If a sequence of bytes contains, say, four or five bytes, something is still needed to fill the buffer and fill the full 24 bits. In these cases, each missing byte is represented by eight 0s and is subsequently converted to padding characters in the finished encoding. Hence the aforementioned 65th character, represented in the coded message with an equal sign (=); only appears at the end of an encoding if a filler is needed.
While base64 was originally intended for transmitting binary data via email messages, its use has come into play in a number of other areas besides MIME. One such fairly common use is for databases and web applications to encode data for creating a URL (Uniform Resource Locator) on a web form. Extensible markup language (XML) also uses a variant that allows binary data, such as small images, to be included within XML documents. There are other variations for encryption methods and other security related techniques like hiding passwords.
Protect your devices with Threat Protection by NordVPN