Work through “Hi”:
- Bytes: 72 and 105 → binary
01001000 01101001. - Regroup into 6-bit chunks:
0100100001011001— values 18, 5, 36. - Alphabet lookup: 18 → S, 5 → G, 36 → k.
- Pad: the input was one byte short of a full group, so one
=ends the output →SGk=.
Decoding reverses the lookup. Any character outside the alphabet, padding in the wrong place, or a length that is not a multiple of 4 means the input is not valid Base64 — this converter tells you the exact position instead of failing silently.