Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a base64 encoded string contain whitespace?

Might a base64 encoded string contain whitespace? Specifically, could it contain whitespace at the end of the string?

PS. I'm thinking about the whole "MySQL will trim trailing whitespace when storing strings in VARCHAR fields" here ;-)

like image 740
Dougal Avatar asked Jun 22 '10 09:06

Dougal


People also ask

What characters are not allowed in Base64?

The base 64 digits in ascending order from zero are the uppercase characters 'A' to 'Z', lowercase characters 'a' to 'z', numerals '0' to '9', and the symbols '+' and '/'. % is not allowed in base64 encoding.

Does Base64 encoding save space?

There is a waste of 2 bits for each 8 bits of transmission data. Â To send three bytes of information (3 times 8 is 24 bits), you need to use four bytes (4 times 6 is again 24 bits). Thus the base64 version of a file is 4/3 larger than it might be. So we use 33% more storage than we could.

What characters can be in a Base64 string?

Base64 only contains A–Z , a–z , 0–9 , + , / and = . So the list of characters not to be used is: all possible characters minus the ones mentioned above. For special purposes .

Is there a limit to Base64 encoding?

The BASE64ENCODE function returns the Base64 encoded version of the binary values of a character string. The schema is SYSTOOLS. A character expression to be encoded. The maximum length in 2732 characters.


1 Answers

No it can't. See Base64 for the allowed character repository used by base64, which are the characters A-Z, a-z, 0-9, + and / (the last two may differ depending on the implementation) as well as the padding character = (but that's also implementation dependent as some implementations don't use padding at all).

like image 63
Stefan Gehrig Avatar answered Sep 30 '22 03:09

Stefan Gehrig