daily pastebin goal
78%
SHARE
TWEET

Untitled

a guest Jan 6th, 2011 155 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl -w
  2.  
  3. # SopPasswd: A generator for Sort-of-pronounceable passwords.
  4. # Version: 0.1
  5. # Author: Mark A. Pors, mark@dreamzpace.com, www.dreamzpace.com
  6. # License: GPL
  7.  
  8. use strict;
  9.  
  10. my $dict = '/usr/share/dict/words';       # path to dict file
  11. my $wordlen = 8;                    # desired length of the password
  12. my $numwords = 10;                 # number of passwords to print
  13. my $sublen = 3;                     # length of the word chunks that create the password
  14. my $sep = "\n";                     # how to separate the words
  15.  
  16. my @dict;
  17.  
  18. $wordlen >= $sublen || die "Error: The word length should be equal or larger than the length of the 'chunks'\n";
  19.  
  20. open (DICT, "<$dict") || die ("Cannot open dict: $!");
  21. while (<DICT>) {
  22.     chomp;
  23.     push (@dict, $_);
  24. }
  25.  
  26. while (1) {
  27.  
  28.     my @sub = ();
  29.     my $word;
  30.     my $parts = int ($wordlen/$sublen);
  31.  
  32.     for (1 .. $parts) {
  33.         my $try = $dict[rand @dict];
  34.         redo if length($try) < $sublen;
  35.         $word .= lc substr($try, 0, $sublen);
  36.     }
  37.  
  38.     my @chars = split(m{}xms, $word);
  39.     my $upper = rand @chars;
  40.     $chars[$upper] = uc $chars[$upper];
  41.     $word = join(q{}, @chars);
  42.  
  43.     my $left = $wordlen % $sublen;
  44.     $word .= substr (int rand (10**($wordlen - 1)), 0, $left);
  45.  
  46.     print $word . $sep;
  47.     chomp (my $exit = <STDIN>);
  48.  
  49. }
RAW Paste Data
Pastebin PRO CHRISTMAS Special!
Get 60% OFF Pastebin PRO accounts!
Top