mjd-perl-pm on Wed, 1 Mar 2000 15:36:58 -0500 (EST) |
Here's what I use: The -n300 option tells it to generate 300 passwords; it generates one by default. #!/usr/bin/perl srand; use Getopt::Std; &getopts('d:n:'); @fruitcake = split //, '~`!@#$%^&*()_+-=[]{}\|;:\'",.<>/?'; $dict = defined($opt_d) ? $opt_d : '/usr/dict/words'; my $nwords = ($opt_n || 1) * 2; open DICT, $dict or die "Couldn't open dictionary file `$dict': $!; aborting"; while (<DICT>) { next unless /^.{3,4}$/; # 3- and 4-letter words only $count++; next unless rand() < $nwords/$count; chomp; if ($GOT >= $nwords) { $words[$nwords * rand] = $_; } else { splice @words, rand(@words+1), 0, $_; } $GOT++; } close DICT; while (@words) { print randcap(shift @words), $fruitcake[rand @fruitcake], randcap(shift @words), "\n"; } sub randcap { my $w = shift; ($w, ucfirst $w, uc $w)[rand 3]; } **Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**
|
|