Encode Your Messages Using Base64

Suhail Roushan πŸš€
3 min readOct 30, 2021

--

Encoding

Encoding and decoding are used in many forms of communications, including computing, data communications, programming, digital electronics, and human communications. These two processes involve changing the format of content for optimal transmission or storage.

In computers, encoding is the process of putting a sequence of c characters (letters, numbers, punctuation, and certain symbols) into a specialized format for efficient transmission or storage. Decoding is the opposite process β€” the conversion of an encoded format back into the original sequence of characters.

These terms should not be confused with encryption and decryption, which focus on hiding and securing data. (We can encrypt data without changing the code or encode data without deliberately concealing the content.)

The Algorithm of base64 Encoding algorithm

Step 1 :

Choose the input string or data

Example: Apple

Step 2 :

Count the number of characters in a String

A ,p,p,l,e

Apple has 5 Characters

Step 3:

Encode the String In ASCII Format

From ASCII Table

A = 65

p = 112

p = 112

l = 108

e = 101

Step 4: Convert the Decimal to Binary in (8 Bit)

A = 65 = 01000001

p = 112 = 01110000

p = 112 = 01110000

l = 108 = 01101100

e = 101 = 01100101

Step 5: Divide the above Binary into chunks of 6-bits

  1. Attach All Binary in One Line And Divide in 6 Part
  2. 0100000101110000011100000110110001100101
  3. Dividing Among 6 Parts
  4. 010000 -1st
  5. 010111 -2nd
  6. 000001 -3rd
  7. 110000 -4th
  8. 011011 -5th
  9. 000110 -6th
  10. 0101 -7th

Step 6: BASE64 TABLE

Base64 Has 64 Characters

(A β€” Z) β€” β€” β€” 1–26

(a-z) β€” β€” β€” 26 -51

(0–9) β€” —–52–61

(+ /) β€” β€” β€” β€” 61–63

( = )β€” β€” β€” β€” β€” β€” 64

Step 7: Convert Those 6 parts to Decimal From The Above Table

010000 -> Q is Character and Decimal is 16

010111 -> X is Character and Decimal is 23

000001 -> B is Character and Decimal is 1

110000 -> w is Character and Decimal is 48

011011 -> b is Character and Decimal is 27

000110 -> G is Character and Decimal is 6

0101 -> U is Character and Decimal is 20

Add Padding = If you have to add two zeros 00

For 2 zeros is equal to (=)

Example 0101 Add 2 zeros in last

010100

0101 = β€˜F’

00 = β€˜=’

010100 = β€˜F =’

Example 2:

String = β€˜THE’

In ASCII For (THE)

T is 84

H is 72

E is 69

Converting that decimal into Binary 8 bit

84–01010100

72–01001000

69–01000101

Diving Whole Binary In 6 Bit Chunks

β€” 84 β€” β€” -β€” 72 β€” β€” β€”69 β€” β€”

01010100 01001000 01000101

010101 = V

000100 =E

100001 =h

000101 = F

Base64 of THE is β€œVEhF”

--

--

Suhail Roushan πŸš€
Suhail Roushan πŸš€

Written by Suhail Roushan πŸš€

Suhail Roushan | Software Engineer @The Hacking School | Instructor @CFI Foundation | Full Stack, DevOps & Automation Enthusiast 🌍 suhailroushan.com

No responses yet