#!/usr/bin/perl
use Crypt::PasswdMD5;
use String::Random;
use MIME::Base64;
use SHA;

if ( $#ARGV != 0 ) {
 print STDERR "cryptword: Usage:\n";
 print STDERR "     cryptword {word}\n";
 exit(1);
}

$randomfoo = new String::Random;
$salt = $randomfoo->randpattern("ss");

$password  = $ARGV[0]; shift;

print "The DES encrypted password for $password is: {crypt}";
print crypt($password,$salt), "\n";

$cryptedpassword = unix_md5_crypt($password, $salt);

print "The MD5 encrypted password for $password is: {md5}";
$encoded = encode_base64($cryptedpassword);
#print "${cryptedpassword} ${encoded}\n";
print "${encoded}";

$sha = new SHA;
$newsalt = pack ("H*", $salt);
$hash = $sha->hash ($password . $newsalt);
#printf ("%s ", unpack ("H*", $hash));
print "The SHA encrypted password for $password is: {sha}";
print encode_base64 ($hash . $salt, "");

exit(0);
#---------------------------------------------------------

Example execution of "cryptword":
# cryptword Secret4
The DES encrypted password for Secret4 is: {crypt}n3vmujR3T5fcU
The MD5 encrypted password for Secret4 is: {md5}JDEkbjMkTVZsWG5jcHFScUovMmxidzdwSDNYLg==
The SHA encrypted password for Secret4 is: {sha}VlNqRC/0HJCfiftkKwoTE8yMTMVuMw==


Your assistance is appreciated.

-- 
Frank Koenen
Director of Technical Services
Monet Technologies Inc.
Email: fkoenen@vonworld.com Voice: 1-312-372-7500 x204 Fax: 1-312-372-6020

