This is an old revision of the document!


<code perl|f password-gen.pl> #!/usr/bin/perl

# code released by David Douthitt into the public domain

use Getopt::Long;

Getopt::Long::Configure('bundling'); GetOptions( 'l=i' ⇒ \$opt_l,

          'p=s' => \$opt_p,
          'm=i' => \$opt_m );

$pat{“ext”} = “punct”; $pat{“alnum”} = “alnum”; $pat{“alpha”} = “alpha”; $pat{“simple”} = “[a-km-z2-9]”; $pat{“normal”} = “[a-km-z2-9A-HJ-NPR-Z]”;

if (defined($opt_p)) {

 if (defined($pat{$opt_p})) {
    $pat = $pat{$opt_p};
 } else {
    print "undefined pattern!\n";
    exit(1);
 }

} else {

 $pat = $pat{"normal"};

}

$max = (defined($opt_m) ? $opt_m : 1000); $len = (defined($opt_l) ? $opt_l : 6);

$x = $len;

for $i (0..$max) {

 $c = chr(int(rand(255)));
 if ($c =~ /$pat/o) {
    $s .= $c;
    if (--$x == 0) {
       print "$s\n";
       $x = $len;
       $s = "";
    }
 }

} </perl>

password.1243874705.txt.gz · Last modified: 2009/06/01 18:45 by a
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready