I'm using a Mac. In Bash, I'm trying to decode a base64 string and then try to print the Hex value. I'm using base64 -d command and then assigning it to a variable.
myText='YYN29+2wV2XRAHymIyhgytWuqY4atgHnIUFfXA7FPOA='
myTextBytes=$(echo -n "$myText" | base64 --decode)
echo -n $myTextBytes | xxd -p -c 99999
The output of the above script is:
618376f7edb05765d17ca6232860cad5aea98e1ab601e721415f5c0ec53ce0
However, if i were to run the following command directly:
echo -n "$myText" | base64 --decode | xxd -p -c 100000
I get:
618376f7edb05765d1007ca6232860cad5aea98e1ab601e721415f5c0ec53ce0
I even tried using openssl enc -base64 and I get the same result. That is, 00 is getting deleted when assigning to a variable. How do I preserve the 00 when I'm assigning it to a variable?