Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I'm using Linux and OS X.

share|improve this question

migrated from serverfault.com Jun 29 '10 at 14:21

This question came from our site for professional system and network administrators.

    
You want to convert Hex or Binary to Base64? Scriptable or is this a one-shot deal? –  Chris S Jun 29 '10 at 14:17

3 Answers 3

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.

share|improve this answer
1  
cat file | xxd -r -p | base64 –  user239558 Mar 26 at 15:13

Well, it depends on the exact formatting of your data. But you can do it with a simple shell scripts:

 echo "obase=10; ibase=16; `cat in.dat`" | bc | base64 > out.dat

Modify as needed depending on your data.

share|improve this answer
2  
That will convert the string of decimal digits. It's not clear if this is what the OP wants or if he has hex digits and wants the bytes they represent converted to base64. –  Dennis Williamson Jun 29 '10 at 14:21

Well, if your hex data is the hex view of a file, just attach the file to a outlook or thunderbird message and then save the message to somewhere. Then open the file with a text editor and see B64 code :)

It functions on Windows, but I think it is a universal way since saving as .EML the attachment is encoded to B64.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.