← Back

#### Bits to Base64

- Tool
- About

How

Welcome again.
Base64 is a mechanism to enable representing and transferring binary data over mediums that allow only printable characters.
The 64 characters used in this technique are:

    Value	Char	Value	Char	Value	Char	Value	Char
    0	A	16	Q	32	g	48	w
    1	B	17	R	33	h	49	x
    2	C	18	S	34	i	50	y
    3	D	19	T	35	j	51	z
    4	E	20	U	36	k	52	0
    5	F	21	V	37	l	53	1
    6	G	22	W	38	m	54	2
    7	H	23	X	39	n	55	3
    8	I	24	Y	40	o	56	4
    9	J	25	Z	41	p	57	5
    10	K	26	a	42	q	58	6
    11	L	27	b	43	r	59	7
    12	M	28	c	44	s	60	8
    13	N	29	d	45	t	61	9
    14	O	30	e	46	u	62	+
    15	P	31	f	47	v	63	/

The character '=' is also used. (for 'padding' purposes)
Let's understand by few examples.
Example 1
Suppose you have a text: "Man". Let's encode it into Base64.
Encoded in ASCII, the characters 'M', 'a' and 'n' are stored as the bytes 77, 97 and 110; or 01001101, 01100001, 01101110.
Then, these are joined into a '24'-bit string, producing: 010011010110000101101110
Now, it is grouped into 6 bits from left-to-right, like: 010011, 010110, 000101, 101110; This gives the Values: 19, 22, 5 and 46; or the characters: T, W, F and u.
That's it. That's the base64 encoded value of "Man": "TWFu"
In the above case, the number of bits were 24 i.e. divisible by 6. But when the number of bits in the string will not be divisible exactly by 6, then what will we do? Let's see.
Example 2
Suppose you have a text: "M". Let's encode it into Base64.
Encoded in ASCII, the characters 'M' is stored as the byte 77; or 01001101.
Making it into a '24'-bit string, gives: 010011010000000000000000
Note that we just added or 'padded' zeroes in the end.
Now, it is grouped into 6 bits from left-to-right, like: 010011, 010000, 000000, 000000; This gives the Values: 19, 16, 0 and 0; or the characters: T, Q, = and =.
Note that 0 means A, but since these are in the end for padding-purpose, '=' sign is used instead.
That's it. That's the base64 encoded value of "M": "TW=="
Example 3
Suppose you have a text: "Ma". Let's encode it into Base64.
Encoded in ASCII, the characters 'M' is stored as the byte 77 and 97; or 01001101 and 01100001.
Making it into a '24'-bit string, gives: 010011010110000100000000
Note that we just added or 'padded' zeroes in the end.
Now, it is grouped into 6 bits from left-to-right, like: 010011, 010110, 000100, 000000; This gives the Values: 19, 22, 4 and 0; or the characters: T, W, E and =.
That's it. That's the base64 encoded value of "Ma": "TWE="
Note: The Binary-to-Base64 conversion in the given 'Tool' works fine only when the input binary string is greater than 8 bits (as it actually is in the real world scenarios).
Next

We have seen what is binary and what are few encoding schemes related to binary. Since, now we know how messages can be converted into 'binary', our real task begins; which is to encrypt those original-plain-bits to cipher-bits (using some key-bits).
To do that, we will first need to explore various 'operations' that can be performed over bits; and then, choose some 'appropriate' operation (or, devise a mechanism which uses that 'appropriate' operation) as our technique for encryption and decryption.
That's next.
See you there.
Bye till then.
:-)
Post-14 Ended.

Input String
Encode (Binary-to-Base64) Decode (Base64-to-Binary)
done
Output String