Base64 is a positional number system with a base of 64 printable ASCII (American Standard Code for Information Interchange) characters. The system is used, for example, to present binary files in e-mail. All Base64 variants use the characters A-Z, a-z and 0-9, 62 characters in total, the missing two characters are replaced by different characters in implementation systems. Every three original bytes are encoded with four characters.
History of Base64
At first, only text could be sent via email (RFC 822). Over time, along with the text, it was necessary to transfer audio, video and graphic files, applications, etc. There was a need to convert a binary file to text. Base64 was added to the then existing UUE encoding (Uuencode), which is used in the MIME (Multipurpose Internet Mail Extensions) specification (RFC 2045-2049).
MIME is a standard for describing headers in electronic messages. Its use allows you to send several attachments in one letter, for example, archived and text files or HTML pages. A MIME-aware email program freely extracts the archive from a text file, displays the message, and parses the HTML tags. For example, Outlook Express automatically runs scripts embedded in an HTML page.
Base64 was born in the era of seven-, six-, and three-bit bytes. Old encodings did not support the eight-bit standard, because of this, part of the information was lost when transferred from the old system to the new one. Often, when sending letters, the mail server dropped an extra, eighth, bit or did not transmit video and images. To eliminate such troubles, encodings for converting binary code to text were developed. The most popular and effective system is Base64, due to its simplicity it is used everywhere.
An algorithm called "encoding for printing" was first described in 1987, Base64 appeared in June 1992. The versions of this system are Base16, Base32, Base36, Base58, Base85, Base91 and Base122. Later standards are actively used in the IT field.
Interesting fact
Some systems use Base58 to encode URLs, which differs from Base64 by the absence of characters in the final text that can be ambiguously perceived by a person. 0 (zero), O (capital Latin o), I (capital Latin i), l (small Latin L) are excluded. Also excluded are the + (plus) and / (slash) characters, which, when encoding a URL, can lead to incorrect interpretation of the address.
Base64 provides reversible and recoverable encoding. The service translates the characters of the eight-bit code table into characters that are preserved during the transfer of information in networks and between devices.