Guest User

Untitled

a guest
Jan 6th, 2011
378
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×