Simple passphrase generator


https://jwenet.net/cgi-bin/mkpf.pl

Generates strings of random characters of the form:

  aaaaa-bbbbb-ccccc-ddddd

Good for PGP/GPG/SSH keys, ugly passphrases for hardcoding into scripts (the horror!), etc.


    #!/usr/bin/perl -w
    #
    use strict;

    my $length   = shift() || 20;
    my $count    = shift() || 20;
    my $okchars  = 'abcdefghijklmnopqrstuvwxyz1234567890';
    my @chars    = split(m##, $okchars);
    my $pool     = scalar(@chars);
    my $sep      = '-';
    my $word     = 6;

    if ($length eq '-?') { print "usage: mkpf [length] [count]\n"; exit(0); }

    foreach my $n (1..$count) {
        printf("\n%2d) ", $n);
        foreach (1..$length) {
            if ( (($_ % $word) == 0) && ($_ != $length) ) { print $sep; }
            else { print $chars[rand($pool)]; }
        }
    }
    print "\n\n";


date: 12/07/2007, updated 12/10/2008