You could save some fiddly typing by using ASCII values with chr in a map to generate your character ranges. I would generate the "salt" for crypt on the fly from the documented allowed characters rather than your mysterious $never_blank_value.
johngg@shiraz ~/perl/Monks $ perl -Mstrict -Mwarnings -E '
my @saltChars = map chr, 46 .. 57, 65 .. 90, 97 .. 122;
my @passChars = map chr, 50 .. 57, 97 .. 107, 109, 110, 112 .. 122;
my $salt = join q{}, map $saltChars[ rand @saltChars ], 1 .. 2;
my $password = join q{}, map $passChars[ rand @passChars ], 1 .. 8;
my $crypted = crypt $password, $salt;
say qq{Salt : $salt};
say qq{Password : $password};
say qq{crypt()ed : $crypted};'
Salt : pI
Password : x3ds5fey
crypt()ed : pIS1tIDqATjmQ
Running this a few times produces
Salt : mQ
Password : jxaijfqu
crypt()ed : mQf.VRB0dpcbk
Salt : /5
Password : h7si8gh9
crypt()ed : /5.1Gj12mBfQY
Salt : Tp
Password : yjqyaikk
crypt()ed : Tp/YoIkhaUEOE
I hope this is helpful.
Update: Fixed missing </code> tag.
|