miniaturellamabird
miniaturellamabird
Champ
2 posts
Don't wanna be here? Send us removal request.
miniaturellamabird · 9 months ago
Text
Base64 encryption logic
Base64 is a binary to a text encoding scheme that represents binary data in an American Standard Code for Information Interchange (ASCII) string format. It’s designed to carry data stored in binary format across the channels, and it takes any form of data and transforms it into a long string of plain text.
This is helpful because every hour of every day, every minute of every hour, and every second of every minute, a tremendous amount of data is being transferred over network channels.
What Is Base64 Encoding?
Base64 encoding is a text encoding string that represents binary data into an ASCII string, allowing it to carry data stored in a binary format across channels.
To better understand base64, we first need to understand data and channels.
As we know, communicating data from one location to another requires some sort of pathway or medium. These pathways or mediums are called communication channels.
What type of data is transferred along these communication channels?
Today, we can transfer any format of data across the globe, and that data can be in the form of text, binary large object file (BLOB) and character large object file (CLOB) format. When that data transfers through a communication medium, it’s chopped into chunks called packets, and each packet contains data in binary format(0101000101001). Each packet then moves through the network in a series of hops.
Before diving into the base64 algorithm, let’s talk about BLOB and CLOB.
More on Software Engineering:Glob Module in Python: Explained
An Introduction to BLOB and CLOB 
BLOB stands for binary large object file. Whenever we transfer image, audio or video data over the network, that data is classified as BLOB data. CLOB, which stands for character large object file, includes any kind of text XML or character data transferred over the network. Now, let’s dive into base64 encoding.
As we stated earlier, base64 is a binary to text encoding scheme that represents data in ACII string format and then carries that data across channels. If your data is made up of 2⁸ bit bytes and your network uses 2⁷ bit bytes, then you won’t be able to transfer those data files. This is where base64 encoding comes in. But, what does base64 mean?
First, let’s discuss the meaning of base64.
base64 = base+64
Base64 is considered a radix-64 representation. It uses only 6 bits(2⁶ = 64 characters) to ensure that humans can read the printable data. But, the question is, why? Since we can also write base65 or base78 encoding, why do we only use 64? 
Base64 encoding contains 64 characters to encode any string.
It contains:
10 numeric values i.e., 0,1,2,3,…..9.
26 Uppercase alphabets i.e., A,B,C,D,…….Z.
26 Lowercase alphabets i.e., a,b,c,d,……..z.
Two special characters i.e., +,/, depending on your OS.
More on Software Engineering:Nlogn and Other Big O Notations Explained
How Base64 Works
In the above example, we’re encoding the string, “THS,” into a base64 format using the base64 operator(<<<) on a Linux CLI. We can see that we’re getting an encoded output: VEhTCg==. Now, let’s dive into the step-by-step procedure of getting this encoded output.
The steps followed by the base64 algorithm include:
Count the number of characters in a string.
If it’s not a multiple of three, pad with a special character, i.e., “=” to make it a multiple of three. 
Encode the string in ASCII format.
Now, it will convert the ASCII to binary format, 8 bit each.
After converting to binary format, it will divide binary data into chunks of 6 bits each.
The chunks of 6-bit binary data will now be converted to decimal number format.
Using the base64 index table, the decimals will be again converted to a string according to the table format.
Finally, we will get the encoded version of our input string.
At the beginning of base64, we started with the string “THS.” Now, we’re going to encode this string by following the above algorithm steps.
https://www.youtube.com/embed/8qkxeZmKmOY?autoplay=0&start=0&rel=0A video on the basics of base64 encoding. | Video: Connor Ashcroft
Base64 Encoding Steps
Finally, we receive the encoded output of base64 as VEhT.
But wait. In the above example, why did we get VEhTCg==?
If we run the echo -n THS | base64 command on CLI, we’ll see that we’re getting the same output as before.
What If Our Input String Isn’t a Multiple of 3?
What do we do if our string is not a multiple of three? According to the first step of the algorithm, base64 will count the number of characters in a given input string. If it’s not multiple of three, then it will pad it with a single “=” character.
Let’s look at one more example to prove it.
In this given string, the number of characters is not multiple of three. So, we have to pad one (=) at the end. But why?
The “=” is padding when the least significant bit of binary data doesn’t contain 6-bit. 
Finally, we’ll return the encoded output, which will be: YWjyYUFicmE=
In this above output, we return K as a special character in place of “=” because this depends on your system. You can try this new command on your CLI for confirmation i.e., echo | base64.
0 notes
miniaturellamabird · 9 months ago
Text
Tumblr media
One sentence joke
What's the best thing about Switzerland? The flag is a big plus.
I went to the aquarium this weekend, but I didn’t stay long. There’s something fishy about that place.
I found a lion in my closet the other day! When I asked what it was doing there, it said “Narnia business.”
What's a cat's favorite instrument? Purr-cussion.
Why did the snail paint a giant S on his car? So when he drove by, people could say: “Look at that S car go!”
What do you call a happy cowboy? A jolly rancher.
What subject do cats like best in school? Hiss-tory.
Humpty Dumpty had a great fall. He said his summer was pretty good too.
My boss said “dress for the job you want, not for the job you have.” So I went in as Batman.
How do you make holy water? You boil the hell out of it.
Justice is a dish best served cold. Otherwise, it's just water.
Why should you never throw grandpa's false teeth at a vehicle? You might denture car.
Why are Christmas trees bad at knitting? They always drop their needles.
What did the lunch box say to the refrigerator? Don't hate me because I'm a little cooler.
I can always tell when someone is lying. I can tell when they're standing too.
Some people pick their nose, but I was born with mine.
1 note · View note