Tuesday, July 07, 2009

Perl - MD5 hex

I have recently being playing around with Perl in order to automate a lot of work. I am a n00b at Perl but am coming on in leaps and bounds. I can read the perl syntax and kinda figure out what the script is doing, however i am not the greatest at writing it.

I was rather impressed to have done the following which turns the word "password" in to a hexidecimal MD5 hash.
Particularly useful when setting up new users on the internal systems at work.

I have managed to incorporate this into a larger script which enables me to pass a varible in to the stored procedure in Windows SQL Server as an MD5 hash. This has saved me an arse!


#!/usr/bin/perl -w
use strict;
use Digest::MD5 qw(md5_hex);
my $md5_data = "password";
my $md5_hash = md5_hex( $md5_data );
print "$md5_hash\n";


So when i run:
>$ ./hash.pl


it returns:

>$ 0f16cff442c47bbbf3b4715d7b39b3d2

0 Comments:

Post a Comment

<< Home