pawgen 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/GPL-2 +339 -0
 - data/GPL-3 +674 -0
 - data/Manifest.txt +7 -0
 - data/README +149 -0
 - data/bin/pawgen +208 -0
 - data/lib/pawgen.rb +412 -0
 - data/pawgen.gemspec +18 -0
 - metadata +54 -0
 
    
        data/README
    ADDED
    
    | 
         @@ -0,0 +1,149 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            This is PawGen, a password generation library capable of
         
     | 
| 
      
 2 
     | 
    
         
            +
            creating Anglophone phonemic, Kana-based phonemic, and
         
     | 
| 
      
 3 
     | 
    
         
            +
            structureless passwords.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            PawGen is implemented in pure Ruby.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            A command line tool is included, too.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            == Sample usage
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              require 'pawgen'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              pwgen = PawGen.new.
         
     | 
| 
      
 15 
     | 
    
         
            +
                  set_length!(16).
         
     | 
| 
      
 16 
     | 
    
         
            +
                  include_symbols!.
         
     | 
| 
      
 17 
     | 
    
         
            +
                  no_uppercase!.
         
     | 
| 
      
 18 
     | 
    
         
            +
                  exclude_ambiguous!
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              10.times do
         
     | 
| 
      
 21 
     | 
    
         
            +
                puts pwgen.anglophonemic
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            == Classes and methods
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            The core class is called [[PawGen]]; it encapsulates the
         
     | 
| 
      
 28 
     | 
    
         
            +
            password generation options.  A set of (more or less) reasonable
         
     | 
| 
      
 29 
     | 
    
         
            +
            defaults is provided.  Optionally after manipulating the options
         
     | 
| 
      
 30 
     | 
    
         
            +
            within, calling [[PawGen#generate]] will generate a random
         
     | 
| 
      
 31 
     | 
    
         
            +
            password, with entropy derived from
         
     | 
| 
      
 32 
     | 
    
         
            +
            [[SecureRandom::random_number]], and return it as a [[String]]
         
     | 
| 
      
 33 
     | 
    
         
            +
            object.  Alternatively, you may call the generation method --
         
     | 
| 
      
 34 
     | 
    
         
            +
            [[PawGen#random]], [[PawGen#anglophonemic]], or
         
     | 
| 
      
 35 
     | 
    
         
            +
            [[PawGen#kanaphonemic]] -- directly.
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            === Constructor
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            The constructor [[PawGen::new]] takes no arguments and returns a
         
     | 
| 
      
 40 
     | 
    
         
            +
            password generator of default options.
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            === Options
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            - Whether to include uppercase letters:
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              - [[include_uppercase!]] requires at least one;
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              - [[no_uppercase!]] prohibits all;
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              - [[include_uppercase?]] queries the current status.
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            - Whether to include digits:
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              - [[include_digits!]] requires at least one;
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              - [[no_digits!]] prohibits all;
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
              - [[include_digits?]] queries the current status.
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            - Whether to include non-letter non-digit printable ASCII
         
     | 
| 
      
 61 
     | 
    
         
            +
              characters:
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              - [[include_symbols!]] requires at least one;
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              - [[no_symbols!]] prohibits all;
         
     | 
| 
      
 66 
     | 
    
         
            +
                characters in them.
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
              - [[include_symbols?]] queries the current status.
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            - Whether to permit letters or digits that may be easily
         
     | 
| 
      
 71 
     | 
    
         
            +
              confused with each other:
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              - [[exclude_ambiguous!]] prohibits all;
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              - [[do_not_exclude_ambiguous!]] or [[dont_exclude_ambiguous!]]
         
     | 
| 
      
 76 
     | 
    
         
            +
                permits them;
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              - [[exclude_ambiguous?]] queries the current status.
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            - Whether to permit vowels (note that only the [[random]]
         
     | 
| 
      
 81 
     | 
    
         
            +
              generator supports generating vowel-less passwords):
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              - [[exclude_vowels!]] prohibits all;
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              - [[do_not_exclude_vowels!]] or [[dont_exclude_vowels!]]
         
     | 
| 
      
 86 
     | 
    
         
            +
                permits them;
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              - [[exclude_vowels?]] queries the current status.
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            - How long a password should be:
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              - [[set_length!(length)]] sets the expected password length
         
     | 
| 
      
 93 
     | 
    
         
            +
                and return the [[PawGen]] instance for method call chaining;
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              - [[length=(length)]] sets the expected password length and
         
     | 
| 
      
 96 
     | 
    
         
            +
                returns it, as expected from assignment operators;
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              - [[length]] queries the current status.
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            - Which generator should be invoked when [[generate]] is called:
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
              - [[use_structureless_generator!]] uses [[structureless]],
         
     | 
| 
      
 103 
     | 
    
         
            +
                which picks each permitted character at equal probability
         
     | 
| 
      
 104 
     | 
    
         
            +
                for each position.  This is the only generator able to
         
     | 
| 
      
 105 
     | 
    
         
            +
                generate passwords when vowel exclusion is required.
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
              - [[use_anglophonemic_generator!]] uses [[anglophonemic]],
         
     | 
| 
      
 108 
     | 
    
         
            +
                which roughly follows Anglophone syllable model in
         
     | 
| 
      
 109 
     | 
    
         
            +
                generating passwords pronounceable to English speakers.
         
     | 
| 
      
 110 
     | 
    
         
            +
                This generator is only able to generate passwords of 5
         
     | 
| 
      
 111 
     | 
    
         
            +
                characters or more.
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
              - [[use_kanaphonemic_generator!]] uses [[kanaphonemic]], which
         
     | 
| 
      
 114 
     | 
    
         
            +
                roughly follows the Japanese mora model.  Such passwords may
         
     | 
| 
      
 115 
     | 
    
         
            +
                also be more convenient than Anglophone phonemic passwords
         
     | 
| 
      
 116 
     | 
    
         
            +
                for speakers of languages such as Estonian, Hawaiian, and
         
     | 
| 
      
 117 
     | 
    
         
            +
                Russian.
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            The generators can also be called directly.
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            == Copyright, credits, and licensing
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            PawGen is copyright (c) 2007-2014 by Andres Soolo.
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            PawGen is strongly inspired by (and includes the Anglophone
         
     | 
| 
      
 128 
     | 
    
         
            +
            phoneme table from) pwgen.
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
            pwgen is copyright (c) 2001-2006 by Theodore Ts'o who used C and
         
     | 
| 
      
 131 
     | 
    
         
            +
            released the work under the GNU GPL v2.
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
            The kanaphonemic password generator is inspired by an unnamed
         
     | 
| 
      
 135 
     | 
    
         
            +
            Estonian language friendly phonemic password generator written
         
     | 
| 
      
 136 
     | 
    
         
            +
            by Andres Soolo and Tõnis Kevvai in Python as a part of the
         
     | 
| 
      
 137 
     | 
    
         
            +
            HotDog web application server in 2001.
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
            HotDog is copyright (c) 2001-2014 by AS Eesti Telekom (formerly
         
     | 
| 
      
 140 
     | 
    
         
            +
            AS Elion, formerly formerly AS Eesti Telefon) who have released
         
     | 
| 
      
 141 
     | 
    
         
            +
            the work under the BSD license.
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
            PawGen is probably sufficiently different from its predecessors
         
     | 
| 
      
 145 
     | 
    
         
            +
            to qualify as an unrelated work under most countries' copyright
         
     | 
| 
      
 146 
     | 
    
         
            +
            laws.  Nevertheless, following the GPL's spirit, PawGen is
         
     | 
| 
      
 147 
     | 
    
         
            +
            hereby published as free software under the terms and conditions
         
     | 
| 
      
 148 
     | 
    
         
            +
            of the GNU General Public License version 2 or (at your option)
         
     | 
| 
      
 149 
     | 
    
         
            +
            any later version.
         
     | 
    
        data/bin/pawgen
    ADDED
    
    | 
         @@ -0,0 +1,208 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #! /usr/bin/ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'pawgen'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'getoptlong'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            VERSION_DATA = "pawgen 1.0.0
         
     | 
| 
      
 9 
     | 
    
         
            +
            Copyright (C) 2007-2014 by Andres Soolo
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            Strongly inspired by the pwgen tool written in and copyrighted
         
     | 
| 
      
 12 
     | 
    
         
            +
            2001-2006 by Theodore T'so who has released the work under the
         
     | 
| 
      
 13 
     | 
    
         
            +
            GNU GPL v2.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Inspired by a part of the HotDog web application server written
         
     | 
| 
      
 16 
     | 
    
         
            +
            in 2001 by Andres Soolo and Tõnis Kevvai and copyrighted
         
     | 
| 
      
 17 
     | 
    
         
            +
            2001-2014 by AS Eesti Telekom (formerly AS Elion, formerly
         
     | 
| 
      
 18 
     | 
    
         
            +
            formerly AS Eesti Telefon) who have released the work under the
         
     | 
| 
      
 19 
     | 
    
         
            +
            BSD license.
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            Licensed under GPLv2+: GNU GPL version 2 or later
         
     | 
| 
      
 22 
     | 
    
         
            +
              <http://gnu.org/licenses/gpl.html>
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            This is free software: you are free to change and
         
     | 
| 
      
 25 
     | 
    
         
            +
            redistribute it.
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            There is NO WARRANTY, to the extent permitted by law.
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            "
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            USAGE = "Usage: pawgen [options] [password-length [count]]
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            Generate random passwords, optionally human memory friendly.
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            --capitalise, --capitalize, -c
         
     | 
| 
      
 36 
     | 
    
         
            +
                Include at least one uppercase letter.  (This is the
         
     | 
| 
      
 37 
     | 
    
         
            +
                default.)
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            --no-capitalise, --no-capitalize, -A
         
     | 
| 
      
 40 
     | 
    
         
            +
                Do not include uppercase letters.
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            --digits, --numerals, -n
         
     | 
| 
      
 43 
     | 
    
         
            +
                Include at least one Arabic digit.  (This is the default.)
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            --no-digits, --no-numerals, -0
         
     | 
| 
      
 46 
     | 
    
         
            +
                Do not include Arabic digits.
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            --symbols, -y
         
     | 
| 
      
 49 
     | 
    
         
            +
                Include at least one symbol (defined as a non-letter
         
     | 
| 
      
 50 
     | 
    
         
            +
                non-digit non-blank printable ASCII character).
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            --no-symbols
         
     | 
| 
      
 53 
     | 
    
         
            +
                Do not include symbols.  (This is the default.)
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            --anglophonemic, --english, -e
         
     | 
| 
      
 56 
     | 
    
         
            +
                Use the Anglophone phonemic generator.  (This is the
         
     | 
| 
      
 57 
     | 
    
         
            +
                default.)
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            --kanaphonemic, --japanese, -j
         
     | 
| 
      
 60 
     | 
    
         
            +
                Use the kana mora based (that is, Japanophone) phonemic
         
     | 
| 
      
 61 
     | 
    
         
            +
                generator.
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            --structureless, -s
         
     | 
| 
      
 64 
     | 
    
         
            +
                Use the structureless generator.  In this mode, each
         
     | 
| 
      
 65 
     | 
    
         
            +
                permitted characters has equal probability of appearing at
         
     | 
| 
      
 66 
     | 
    
         
            +
                each position.
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            --no-ambiguous, -B
         
     | 
| 
      
 69 
     | 
    
         
            +
                Exclude letters and digits that may be easily confused with
         
     | 
| 
      
 70 
     | 
    
         
            +
                each other such as the letter O and the digit 0 (but also
         
     | 
| 
      
 71 
     | 
    
         
            +
                others).
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            --permit-ambiguous
         
     | 
| 
      
 74 
     | 
    
         
            +
                Permit letters and digits that may be easily confused with
         
     | 
| 
      
 75 
     | 
    
         
            +
                each other.  (This is the default.)
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            --no-vowels, -v
         
     | 
| 
      
 78 
     | 
    
         
            +
                Exclude vowels.  (The only generator supporting this is
         
     | 
| 
      
 79 
     | 
    
         
            +
                --structureless.)
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            --permit-vowels
         
     | 
| 
      
 82 
     | 
    
         
            +
                Permit vowels in the generated passwords.  (This is the
         
     | 
| 
      
 83 
     | 
    
         
            +
                default.)
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            --help
         
     | 
| 
      
 86 
     | 
    
         
            +
                Print this usage.
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            --version
         
     | 
| 
      
 89 
     | 
    
         
            +
                Show version data.
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            By default, 12 passwords are is generated if the standard output
         
     | 
| 
      
 93 
     | 
    
         
            +
            is a teletype and one otherwise (f. e., if it's a pipe).
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            Report bugs to: <dig@mirky.net>
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
            "
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            $0 = 'pawgen'
         
     | 
| 
      
 100 
     | 
    
         
            +
            $count = $stdout.tty? ? 12 : 1
         
     | 
| 
      
 101 
     | 
    
         
            +
            begin
         
     | 
| 
      
 102 
     | 
    
         
            +
              $pawgen = PawGen.new
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
              GetoptLong.new(
         
     | 
| 
      
 105 
     | 
    
         
            +
                ['--capitalise', '--capitalize', '-c',
         
     | 
| 
      
 106 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 107 
     | 
    
         
            +
                ['--no-capitalise', '--no-capitalize', '-A',
         
     | 
| 
      
 108 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 109 
     | 
    
         
            +
                ['--digits', '--numerals', '-n',
         
     | 
| 
      
 110 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 111 
     | 
    
         
            +
                ['--no-digits', '--no-numerals', '-0',
         
     | 
| 
      
 112 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 113 
     | 
    
         
            +
                ['--symbols', '-y',
         
     | 
| 
      
 114 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 115 
     | 
    
         
            +
                ['--no-symbols',
         
     | 
| 
      
 116 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 117 
     | 
    
         
            +
                ['--anglophonemic', '--english', '-e',
         
     | 
| 
      
 118 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 119 
     | 
    
         
            +
                ['--kanaphonemic', '--japanese', '-j',
         
     | 
| 
      
 120 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 121 
     | 
    
         
            +
                ['--structureless', '-s',
         
     | 
| 
      
 122 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 123 
     | 
    
         
            +
                ['--permit-ambiguous',
         
     | 
| 
      
 124 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 125 
     | 
    
         
            +
                ['--no-ambiguous', '-B',
         
     | 
| 
      
 126 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 127 
     | 
    
         
            +
                ['--permit-vowels',
         
     | 
| 
      
 128 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 129 
     | 
    
         
            +
                ['--no-vowels', '-v',
         
     | 
| 
      
 130 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 131 
     | 
    
         
            +
                ['--help',
         
     | 
| 
      
 132 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 133 
     | 
    
         
            +
                ['--version',
         
     | 
| 
      
 134 
     | 
    
         
            +
                    GetoptLong::NO_ARGUMENT],
         
     | 
| 
      
 135 
     | 
    
         
            +
              ).each do |opt, arg|
         
     | 
| 
      
 136 
     | 
    
         
            +
                case opt
         
     | 
| 
      
 137 
     | 
    
         
            +
                  when '--capitalise' then
         
     | 
| 
      
 138 
     | 
    
         
            +
                    $pawgen.include_uppercase!
         
     | 
| 
      
 139 
     | 
    
         
            +
                  when '--no-capitalise' then
         
     | 
| 
      
 140 
     | 
    
         
            +
                    $pawgen.no_uppercase!
         
     | 
| 
      
 141 
     | 
    
         
            +
                  when '--digits' then
         
     | 
| 
      
 142 
     | 
    
         
            +
                    $pawgen.include_digits!
         
     | 
| 
      
 143 
     | 
    
         
            +
                  when '--no-digits' then
         
     | 
| 
      
 144 
     | 
    
         
            +
                    $pawgen.no_digits!
         
     | 
| 
      
 145 
     | 
    
         
            +
                  when '--symbols' then
         
     | 
| 
      
 146 
     | 
    
         
            +
                    $pawgen.include_symbols!
         
     | 
| 
      
 147 
     | 
    
         
            +
                  when '--no-symbols' then
         
     | 
| 
      
 148 
     | 
    
         
            +
                    $pawgen.no_symbols!
         
     | 
| 
      
 149 
     | 
    
         
            +
                  when '--anglophonemic' then
         
     | 
| 
      
 150 
     | 
    
         
            +
                    $pawgen.use_anglophonemic_generator!
         
     | 
| 
      
 151 
     | 
    
         
            +
                  when '--kanaphonemic' then
         
     | 
| 
      
 152 
     | 
    
         
            +
                    $pawgen.use_kanaphonemic_generator!
         
     | 
| 
      
 153 
     | 
    
         
            +
                  when '--structureless' then
         
     | 
| 
      
 154 
     | 
    
         
            +
                    $pawgen.use_structureless_generator!
         
     | 
| 
      
 155 
     | 
    
         
            +
                  when '--permit-ambiguous' then
         
     | 
| 
      
 156 
     | 
    
         
            +
                    $pawgen.do_not_exclude_ambiguous!
         
     | 
| 
      
 157 
     | 
    
         
            +
                  when '--no-ambiguous' then
         
     | 
| 
      
 158 
     | 
    
         
            +
                    $pawgen.exclude_ambiguous!
         
     | 
| 
      
 159 
     | 
    
         
            +
                  when '--permit-vowels' then
         
     | 
| 
      
 160 
     | 
    
         
            +
                    $pawgen.do_not_exclude_vowels!
         
     | 
| 
      
 161 
     | 
    
         
            +
                  when '--no-vowels' then
         
     | 
| 
      
 162 
     | 
    
         
            +
                    $pawgen.exclude_vowels!
         
     | 
| 
      
 163 
     | 
    
         
            +
                  when '--help' then
         
     | 
| 
      
 164 
     | 
    
         
            +
                    puts USAGE
         
     | 
| 
      
 165 
     | 
    
         
            +
                    exit 0
         
     | 
| 
      
 166 
     | 
    
         
            +
                  when '--version' then
         
     | 
| 
      
 167 
     | 
    
         
            +
                    puts VERSION_DATA 
         
     | 
| 
      
 168 
     | 
    
         
            +
                    exit 0
         
     | 
| 
      
 169 
     | 
    
         
            +
                  else
         
     | 
| 
      
 170 
     | 
    
         
            +
                    raise 'assertion failed'
         
     | 
| 
      
 171 
     | 
    
         
            +
                end
         
     | 
| 
      
 172 
     | 
    
         
            +
              end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
      
 174 
     | 
    
         
            +
              if ARGV.length >= 1 then
         
     | 
| 
      
 175 
     | 
    
         
            +
                length = ARGV[0].to_i
         
     | 
| 
      
 176 
     | 
    
         
            +
                unless length >= 1 then
         
     | 
| 
      
 177 
     | 
    
         
            +
                  $stderr.puts "pawgen: invalid password length"
         
     | 
| 
      
 178 
     | 
    
         
            +
                  exit 1
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
      
 180 
     | 
    
         
            +
                $pawgen.length = length
         
     | 
| 
      
 181 
     | 
    
         
            +
              end
         
     | 
| 
      
 182 
     | 
    
         
            +
             
     | 
| 
      
 183 
     | 
    
         
            +
              if ARGV.length >= 2 then
         
     | 
| 
      
 184 
     | 
    
         
            +
                $count = ARGV[1].to_i
         
     | 
| 
      
 185 
     | 
    
         
            +
                unless $count >= 1 then
         
     | 
| 
      
 186 
     | 
    
         
            +
                  $stderr.puts "pawgen: invalid password count"
         
     | 
| 
      
 187 
     | 
    
         
            +
                  exit 1
         
     | 
| 
      
 188 
     | 
    
         
            +
                end
         
     | 
| 
      
 189 
     | 
    
         
            +
              end
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
              if ARGV.length > 2 then
         
     | 
| 
      
 192 
     | 
    
         
            +
                $stderr.puts "pawgen: too many arguments"
         
     | 
| 
      
 193 
     | 
    
         
            +
                exit 1
         
     | 
| 
      
 194 
     | 
    
         
            +
              end
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
            rescue GetoptLong::Error => e
         
     | 
| 
      
 197 
     | 
    
         
            +
              # no need to display; it has already been reported
         
     | 
| 
      
 198 
     | 
    
         
            +
              exit 1
         
     | 
| 
      
 199 
     | 
    
         
            +
            end
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
            begin
         
     | 
| 
      
 202 
     | 
    
         
            +
              $count.times do
         
     | 
| 
      
 203 
     | 
    
         
            +
                puts $pawgen.generate
         
     | 
| 
      
 204 
     | 
    
         
            +
              end
         
     | 
| 
      
 205 
     | 
    
         
            +
            rescue StandardError => e
         
     | 
| 
      
 206 
     | 
    
         
            +
              $stderr.puts "pawgen: #{e}"
         
     | 
| 
      
 207 
     | 
    
         
            +
              exit 1
         
     | 
| 
      
 208 
     | 
    
         
            +
            end
         
     |