Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting hex string to bytes? 1

Status
Not open for further replies.

piquazhang

Programmer
Jun 10, 2003
1
US
Hello! I am trying to test an encryption algorithm, and I am given a string of plain text in hexadecimal "14 00 00 24 ..."
and also a key in hexadecimal. The program I am using takes a key file and a plaintext file, and displays the cipher text on the screen.

Is there a simple UNIX command that takes a hexidecimal string and allows me to pipe the output to a file?

Thanks for your help!
Susan
 
If you pipe your hex dump through this script it should do it:

[tt]perl -e 'while (<STDIN>) { split ; foreach (@_) { printf(&quot;%c&quot;,int) } }'[/tt]

Annihilannic.
 
Oops. That converts decimal ASCII values to binary. This should do what you want:

[tt]perl -e 'while (<STDIN>) { split ; foreach (@_) { printf(&quot;%c&quot;,hex) } }'[/tt]

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top