Base64 Explained
Base 64 is used everywhere. It is the most known and famous encoding scheme that is used to represent binary data and transform it into an ASCII representation. Why do we use it? What is the algorithm? And how does it actually work?
We use base 64 as a method to encode binary data into an ASCII representation.
Why?
We do so since many systems and networks just don’t represent binary data as it is supposed to be shown. So how does it actually work?
Let’s do it by example. Let’s take the word FortiGate. Each character has an eight-bit representation.
If we will convert each character into its own ASCII binary presentation,
We will see for example, that the character F has a value of 102,
which’s the decimal value of the character. If we convert it into a binary presentation, we will get 01100110.
Let's convert each character into their binary representation
Now take the different bits, the different character bits, and regroup them in a six binary digit format. That is taking each byte last two bits and add them up to the next eight-bit.
By doing so, we will have six-digit binary groups. more groups than we had before.
Now take each group and convert it into its own decimal number.
So now the first group is actually 25, converting it into its own decimal value, the second group is 38, and so on.
Base64 table
Now, take the base 64 encoding table which you can find just about everywhere ( Google ) And each decimal value has its own representation in base 64.
25 is actually Z 38 is m, converting that way, you will find out that the word FortiGate is actually in base 64 Z M, 9 Y, D G L N Y X R L.
Let’s now do it using a Python script and check it out.
My Book Of secrets — Cryptography Handbook for beginners