What Is Binary Encoding

by Staff Coder

on November 21, 2019

What Is Binary Encoding?

Binary encoding is a procedure to convert data to a form that allows the data to be easily used by difference computer operating systems. This achieved by converting binary data to a ASCII string format, specifically, converting 8-bit data into a 7-bit format, that use as standard set of ASCII printable characters. ASCII, American Standard Code for Information Interchange, was developed by AT&T in the early 1960s And is the most widely used character encoding format. Modern character encoding continues to be base on ASCII although it support many additional characters and different languages.

What Is Base64 Encoding?

Base64 provides a safe way to transfer binary data as only printable ASCII characters over a computer network. Data can safely be transferred without an possibility of loosing data due to confusion of control characters. Base 64 encoding is the most popular of the character “base encoding” that includes format such as Base 16 or Base 32. Base64 offers a high level of interoperable among a wide variety of different systems.

Base 64 Alphabet

Base64 used the following subset of the US-ASCII characters.

[0-9] – 10 characters
[a-z] – 26 characters
[A-Z] – 26 characters
[/] - 1 character [filler character] [+] - 1 character [filler character] [=] - Used for Padding purposes, as explained later.

Base64 uses 6 -bits. This allows up 64 characters. You will notice that the total number of upper case letters, lower case letters and digits, add up to 62. The ‘+’ and ‘/’ are designated as filler and fills the gap to account for 64 characters.

Base 64 alphabet

The characters in the Base 64 alphabet includes, ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz/+

Base64 Encode

Base64 converts a sequence of bytes into a sequence of characters, each representing six bits. Each sequence of three unencoded bytes will fall neatly into a sequence of four encoded characters, each representing the same twenty-four bits.

If the sequence of bytes to encode doesn’t fall evenly into three bytes at a time, the remaining bytes are still sequenced into four encoded characters. Equals signs are used to represent the filler portion that will not be decoded into the original data. Depending on the length of the original data, the encoded characters may end in zero, one or two equals signs.

Practical Uses Of Base64 Encode

  • Base64 on one of the main pillar that supports the construction and operation of emails messages. Base64 is integral in the structuring emails that need attachments like image, video, documents or any other file formats.

  • Base-64 can encode and transfer any sets of binary data through dissimilar system and then decode them to the original binary data.

  • XML documents can be used to store binary content. Binary data can be base-64 encoded and be specified inline within any XML 1.0 document.

  • HTTP basic authentication is encoded using the RFC2045-MIME variant of Base64, except that is not limited to 76 character per line. Both the username and password is combined with a single colon.
    It is not done for security reasons but as a means of escaping special characters.