How Base64 works
Base64 takes the input three bytes (24 bits) at a time and splits them into four 6-bit numbers. Each number from 0 to 63 maps to one character: A–Z, a–z, 0–9, + and /. For example, the text Man becomes TWFu.
When the input length isn't a multiple of three, the output is padded with one or two = characters so its length is always a multiple of four.