How Base64 Content Encoding Works

How Base64 Content Encoding Works

The term “Base64” refers to a specific MIME content-transfer encoding. It’s also used as a generic term for any similar encoding scheme that encodes binary data by treating it numerically and translating it into a base-64 representation. The particular choice of base is due to the history of character set encoding; one can choose a set of 64 characters that is both part of the subset common to most encodings, and also printable. This combination leaves the data unlikely to be modified in transit through systems, such as email, which were not intended for handling binary data.

Base64 to the Rescue

Base64 encoding uses three eight-bit bytes that represent four printable ASCII characters. The encoding requires two steps.

The first step converts three bytes to four numbers of six bits. Each character in the ASCII standard consists of seven bits. Base64 uses only six bits (corresponding to 2^6 = 64 characters) to ensure the encoded data is both printable and humanly readable?the process doesn’t use any of the special characters available in ASCII. These 64 characters (hence the name Base64) include 10 digits, 26 lowercase characters, 26 uppercase characters, and the plus (+) and forward slash (/) symbols.

For example, if you start with the three bytes 155, 162, and 233, the corresponding (and intimidating) bit stream is 100110111010001011101001, which in turn corresponds to the 6-bit values 38, 58, 11, and 41.

The second step converts these numbers to ASCII characters using the Base64 encoding table. In the example, the four 6-bit numbers translate to the ASCII sequence “m6Lp”.

155 -> 10011011 162 -> 10100010 233 -> 11101001 100110 -> 38 111010 -> 58 001011 -> 11 101001 -> 41 38 -> m 58 -> 6 11 -> L 41 -> p 

This two-step process gets applied to the entire sequence of bytes to be encoded. To ensure that the encoded data can be printed properly, and does not exceed any mail server’s line-length limit, the conversion process inserts newline characters to keep line lengths below 76 characters. The process encodes the newline characters just like all the other data.

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as