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.