Base64

Coding, which is based on a 64 number system

ASCII characters consist of 8 bits. Base64 encodes 8-bit characters as 6-bit characters. That was necessary for the email protocol SMTP in its original version, which allows only a maximum of 7 bits for characters. The encoding increases the size of the data by 36%.

Only the characters A-Z, a-z, 0-9, + and = are used. If the total number of input bits is not evenly divisible by 24, zeros are added as filling bits by Base64.
Complete filling bytes (8 bits) are encoded by an =. If the message "ABBA" should be encoded, the following sequence of bits would result according to the ASCII table:
01000001 01000010 01000010 01000001
This sequence of bits is now divided into 6-bit blocks and filled with (4) zeros at the end until the number of bits is divisible by 24.
010000 010100 001001 000010 010000 010000 000000 000000
Additionally, 2 closing bytes have been added at the end of the sequence. Therefore, the codeword contains two = characters at the end. The remaining sequences are translated according to the code table:

Base64

Character

Base64

Character

Base64

Character

Base64

Character

000000

A

010000

Q

100000

g

110000

w

000001

B

010001

R

100001

h

110001

x

000010

C

010010

S

100010

i

110010

y

000011

D

010011

T

100011

j

110011

z

000100

E

010100

U

100100

k

110100

0

000101

F

010101

V

100101

l

110101

1

000110

G

010110

W

100110

m

110110

2

000111

H

010111

X

100111

n

110111

3

001000

I

011000

Y

101000

o

111000

4

001001

J

011001

Z

101001

p

111001

5

001010

K

011010

a

101010

q

111010

6

001011

L

011011

b

101011

r

111011

7

001100

M

011100

c

101100

s

111100

8

001101

N

011101

d

101101

t

111101

9

001110

O

011110

e

101110

u

111110

+

001111

P

011111

f

101111

v

111111

/


The result of the encoding process is: QUJCQQ==