Command:
echo "HelloWorld==" | base64 -d | base64
Output:
HelloWorlQ==
Why is my d
now a Q
?
Edit:
I am not trying to start with arbitrary data and base64 encode it. My intention is to start with Base64 and end with Base64, having only produced a binary value in the interim.
Edit 2:
I have noticed that it does not happen if the input string has is a multiple of four characters, so I think it is an interaction with the padding somehow:
❯ echo 'abcdefghij==' | base64 -d | base64
abcdefghig==
❯ echo 'abcdefgh' | base64 -d | base64
abcdefgh
Edit 3
Removed confusing mention of the -i
flag, which turned out to have nothing to do with my problem.
echo -n
doesn't change anything. – MatrixManAtYrService Aug 25 '19 at 21:02base64 -id
. e.g.echo SGVsbG8gV29ybGQhPT0K | base64 -id | base64
. or, at least, the actual data you're piping. PipingHello World!==
into it just makes the question confusing. BTW, this also answers the question - whatever your actual input is, it is not valid base64. – cas Aug 26 '19 at 02:41-i
flag, because I agree it was confusing. I'm leaving the invalid base64 because if it were suddenly valid then the question wouldn't make sense. – MatrixManAtYrService Aug 27 '19 at 01:51