The basic encoding of a byte string is longer than the byte string, because this byte string has 2 ^ 8 possibilities for a "location", whereas a basic 64-string has only 2 ^ 6 possibilities for each location (therefore we call it base 64).
Think of the logarithms and holes of pigeons. Take number 5000. How many places (pigeon holes, bytes) do you need to store it in the 256 base?
"Locations in base256" = ceil(log_2(5000) / 8) = ceil(1.54) = 2
Where log_2 tells you how many bits you need. Now how much is base64?
"Locations in base64" = ceil(log_2(5000) / 6) = ceil(2.04) = 3
Frank krueger
source share