LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-Oct-2009, 06:20 PM
Cool Solutions RSS Poster
 
Join Date: Sep 2007
Posts: 20
Cool Solutions 1-9 reputation points
Default Base64-to-hexadecimal converter

Base64-to-hexadecimal converter
01-Oct-2009 11:29 AM

Earlier a need to convert base64-encoded values to the appropriate hexademical string came up and needed to be done multiple times from the command line in a scripted fashion. Unfortunately the latter requirement prevented me from using a website that does the conversions (at least, without a bit of work) as I usually use this one:

http://home2.paulschou.net/tools/xlate/

So off to Perl to see how quickly I could conjure something up. With the help of pre-installed and available MIME modules for Perl and some tips from Google on the best way to print data in its hex form this little script came into being. It is not an overly-high performer as it only takes one string per invocation but it could easily be adapted to read from another source and then process multiple times without loading a new Perl environment every time. In the meantime it either takes STDIN base64-encoded values or it will prompt for values. Everything except the actual hash is written to STDERR so you can filter that out and process from there if needed.

ab@mybox0: ~> echo 'RR19QlE2ED2IDSMhVKKjc0mpe4Lxx7nhHgyXBQ1wbKY=' | ./base64tohex.pl

ab@mybox0: ~> ./base64tohex.pl RR19QlE2ED2IDSMhVKKjc0mpe4Lxx7nhHgyXBQ1wbKY=




More...
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -6. The time now is 05:39 AM.


© 2007 Novell, Inc. All Rights Reserved.

Search Engine Friendly URLs by vBSEO 3.3.0 RC2