On 18 Aug 1998, Jason L Tibbitts III wrote:
> Anyone have code to generate a reasonable password randomly? I feel that
> assigning random garbage as initial passwords is just going to result in
> people not using them.
This code generates alphanumeric passwords of different forms in a fairly
easy to expand way. I already use something like this to give out list
passwords.
#!/usr/bin/perl
srand(time+$$);
sub f
{
return substr(@_[0],int(rand(length(@_[0]))),1);
}
@forms=qw/
xxxxxxx
xxxxxx0
000xxxx
xxx0000
xxxx000
0xxxxx0
xxxxx00
00xxxxx
xxx00xxx
00xxxx00
Cvcvcvc
cvcvc000
000cvcvc
Cvcvcvc0
xxx00000/;
%groups= (
'x' => "abcdefghijkmnpqrstuvwxyz",
'X' => "ABCDEFGHJKLMNPQRSTUVWXYZ",
'c' => "bcdfghjklmnpqrstvwxyz",
'C' => "BCDFGHJKLMNPQRSTVWXYZ",
'v' => "aeiou",
'V' => "AEIOU",
'0' => "0123456789"
);
$pw=$forms[int(rand(@forms))];
$pw=~s/(.)/f($groups{$1})/ge;
print "$pw\n";
--
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."
References:
-
Quickies
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
|
|