Is there anyway to ensure that a base64 encoded string never includes a non-alphanumerical character?
For example, if I have a long string that I encode, is there something I can prepend or append to it that will ensure that when encoded with base64 will only include letters and numbers in the encoded string? Something like this:
String: 192.168.1.1
Encoded: MTkyLjE2OC4xLjE= <- I want to ‘get rid’ of the equal sign.
I tried appending } at the end of the string (new string is now 192.168.1.1}), and this worked (new encoded string: MTkyLjE2OC4xLjF9), but is there a method of ensuring every combination works?
Is this possible?
You can just rtrim() the equals signs away, which is what most people do.
but as for your question: when length of string / 3 is a whole number. So:
but yeah, the parser will add the equals signs back in automatically just like that, to a multiple of 4, when you pass the string back in – so you dont need to keep them.