#!/usr/bin/perl -w # cryptmd5.pl -- simple tool to use Crypt::PasswdMD5 use strict; use vars qw($password $itoa64 $i $buf); use Crypt::PasswdMD5; if(! defined $ARGV[0]) { die "What's the password?\n"; } $password = $ARGV[0]; $password = unix_md5_crypt($password, get_salt()); print $password . "\n"; sub get_salt { # salt values, straight from Crypt::PasswdMD5 $itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; my $buf = ""; for($i = 0; $i < 2; $i++) { $buf .= substr $itoa64, rand(length($itoa64)), 1; } return $buf; }