Simple using the modules of MD5 (125 b) and SHA1 (160 b) algoritms...
#!/usr/bin/perl -w
use Digest::MD5 qw(md5_hex);
use Digest:SHA1 qw(sha1_hex);
if (@ARGV !=1)
{
print "Usage: perl $0 <word to encrypt>\n";
exit;
}
($var) = @ARGV;
print "\n$var (MD5)" . " : " . md5_hex("$var")."\n";
print "$var (SHA1)" . " : " . sha1_hex("$var")."\n";
#hawkee.com
if (@ARGV !=1)
@ARGV is a list, it will not work because you are comparing the array to an integer. The correct term you'd need is $#ARGV.
If ($#ARGV != 1) { do stuff }
($var) = @ARGV; you are distributing @ARGV into ($var), var is now a list therefore you cant use it this way: print "\n$var (MD5)" . " : " . md5_hex("$var")."\n"; you'd need to access the elements for example $var[0]