#!/usr/bin/perl # altblue 2000 ############ my ($minlen,$maxlen) = (8,32); my $password = defined $ARGV[0] ? $ARGV[0] : random_hash($minlen,$maxlen); use Crypt::PasswdMD5; $|=1; print "Password:\t$password\n"; my ($salt,$cryptass); $salt = &random_hash(2,2); $cryptass = crypt($password,$salt); print "DES:\t\t$cryptass\n"; $salt = &random_hash; $cryptass = unix_md5_crypt($ARGV[0], $salt); print "MD5:\t\t$cryptass\n"; exit 0; ############################################### # gimme_hash([min_len] [,max_len]) # defaults: # min_len: 4 # max_len: 8 ############## sub random_hash { my($ml,$Ml) = @_; $ml = $ml ? int($ml) : 4; $Ml = $Ml ? int($Ml) : 8; if($ml>$Ml) { $ml=1; $Ml=8; } my $r = $ml+int(rand($Ml-$ml)); my $itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; my $ash=''; while($r) { $ash .= substr($itoa64,rand(length($itoa64)),1); $r--; } return $ash; }