How to convert from hex to base64

base64encoding

Can anyone recommend a straightforward way/tool to convert hex to base64?

I'm using Linux and OS X.

Best Answer

Use xxd with the -r argument (and possibly the -p argument) to convert from hex to plain binary/octets and base64 to convert the binary/octet form to base64.

For a file:

cat file.dat | xxd -r -p | base64

For a string of hex numbers:

echo "6F0AD0BFEE7D4B478AFED096E03CD80A" | xxd -r -p | base64
Related Question