Decode Base64: Invalid Input

decode base64: invalid input

That version will not decode (by default) lines with separators, yet the encoder does that by default. (Newer versions don't have this problem.)

One solution:

base64 -w 0 | base64 -d >


base64 | base64 -di >

The -i option stands for (from the man page):

-i, --ignore-garbage
When decoding, ignore non-alphabet characters.
Decoding require compliant input by default, use --ignore-garbage to
attempt to recover from non-alphabet characters (such as newlines)

base64 digest- invalid input?

Your data is invalid, probably partial. A valid base64 encoded string should have a length multiple of 4. So the different digest output is expected.

base64 gives incorrect result

echo adds a '\n' ; try echo -n

$ echo -n qwerty | base64 

Why doesn't base64_decode return false on invalid input?

Try to do base64_decode("", TRUE);

The ,TRUE puts it in "strict mode". Which means it will return FALSE if the string contains invalid characters.

Related Topics

Leave a reply