I read somewhere that when encoding a password in base64, I should use echo -n
to prevent the newline from being included in the encoded value. For example,
echo changeme | base64
Y2hhbmdlbWUK
echo -n changeme | base64
Y2hhbmdlbWU=
These two base64 strings are different, but when I decode them they are the same
echo Y2hhbmdlbWUK | base64 -d
changeme
echo Y2hhbmdlbWU= | base64 -d
changeme
So do I really need to add the -n
option https://linux.die.net/man/1/echo
says:
do not output the trailing newline
Searches gave this long winded example using python... didn't read it all Simple way to encode a string according to a password?