Learn something new every day
More Info... by email
Base64 is a method for converting arbitrary binary data, data comprised of more than just plain text characters, into a plain text message that can then be transferred across a computer network. It's what's called an encoding. While the output of a base64 encoded message is not something a human can readily understand, it is still comprised of 64 common English language characters, which is where the name comes from, with an additional 65th character used for special purposes.
The idea behind base64 came about as the need arose to get more than simple text characters through networked communications such as email. The first email messages started out as characters encoded in the American Standard Code for Information Interchange (ASCII), the encoding method used in computers for representing English language alphabet characters as text on displays or printers. As additional binary information needed to get through, new encoding schemes were developed.
The base64 encoding method was first described in what's known as the Multipurpose Internet Mail Extensions (MIME) standard. The MIME standard defined methods by which other characters that weren't ASCII-encoded, such as alphabets used by non-English languages, as well as other arbitrary binary data, could also be encoded into ASCII sequences and transmitted via email messages. Of the two primary means of encoding described by the MIME standard, base64 shares the role with another known as quoted-printable. While the quoted-printable method is capable of extending ASCII somewhat beyond its limited 94 printable characters, base64 can take any sequence of bytes and convert it into an ASCII sequence.
Base64 needs to take strings of data that wouldn't otherwise meet the ASCII standard and convert them into ASCII. To do this, the encoding method is a process of gathering the data into groups of three bytes and converting them into four numbers that represent corresponding ASCII characters. Since a byte is eight bits, where each bit is represented by either a one or zero, three bytes are linked end to end and the whole sequence goes into a 24-bit buffer. The 24 ones and zeros are then split up into four groups of six bits, where each is then assigned numbers that match an ASCII character.
Since base64 is capable of encoding any binary data, any sequence of bytes can go through the process. There is a catch, however, in those instances where the number of bytes for encoding aren't divisible by three so that the bits can fit into the buffer. If a byte sequence contains, say, four or five bytes, something is still needed to fill the buffer and make up the full 24 bits. In these cases, each missing byte is represented by eight 0s and is subsequently converted into padding characters in the finished encoding. This is where the previously mentioned 65th character comes from, represented in the encoded message with an equals sign (=); it only ever appears at the very end of an encoding should a filler be necessary.
Although base64 was originally devised for transmitting binary data via email messages, its usage has come into play in a number of other areas besides MIME. One such fairly common use is for web databases and applications to encode data for the creation of a uniform resource locator (URL) on a web form. The extensible markup language (XML) also uses a variant that allows for binary data, such as small images, to be included within XML documents. Other variations exist for encryption methods and other security-related techniques such as hiding passwords.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!