pwqgen.rb 0.0.2 → 0.0.3.pre
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.
- data/.travis.yml +3 -1
- data/ChangeLog +6 -0
- data/README.md +31 -8
- data/Rakefile +11 -3
- data/bin/pwqgen.rb +5 -5
- data/doc/ChangeLog.html +14 -0
- data/doc/Gemfile.html +4 -2
- data/doc/Pwqgen.html +104 -6
- data/doc/Pwqgen/Generator.html +20 -6
- data/doc/Rakefile.html +94 -0
- data/doc/created.rid +11 -8
- data/doc/index.html +2 -0
- data/doc/js/search_index.js +1 -1
- data/doc/table_of_contents.html +9 -0
- data/features/password_generation.feature +21 -0
- data/features/step_definitions/pwqgen.rb_steps.rb +1 -0
- data/features/support/env.rb +17 -0
- data/lib/pwqgen/pwqgen.rb +37 -1
- data/lib/pwqgen/version.rb +1 -1
- data/pwqgen.rb.gemspec +2 -1
- data/spec/lib/pwqgen_spec.rb +32 -0
- metadata +29 -5
data/.travis.yml
CHANGED
data/ChangeLog
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](http://travis-ci.org/iphoting/pwqgen.rb) [](https://gemnasium.com/iphoting/pwqgen.rb)
|
4
4
|
|
5
|
-
pwqgen.rb is a Ruby implementation of passwdqc's pwqgen password generator.
|
5
|
+
pwqgen.rb is a Ruby implementation of passwdqc's pwqgen, a random pronouncable password generator.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -13,23 +13,46 @@ gem install pwqgen.rb
|
|
13
13
|
## Usage
|
14
14
|
|
15
15
|
### CLI
|
16
|
+
You can generate a random password from the command line.
|
16
17
|
```
|
17
|
-
$ pwqgen.rb
|
18
|
+
$ pwqgen.rb --help
|
19
|
+
Usage: pwqgen.rb [options] [<length>]
|
20
|
+
|
21
|
+
Options:
|
22
|
+
-h, --help show this help message and exit
|
23
|
+
-v, --version show version and exit
|
24
|
+
|
25
|
+
<length>: Number of words in the passphrase. [default: 3]
|
18
26
|
```
|
19
27
|
|
20
28
|
### Ruby App
|
29
|
+
You can `require` it within your app:
|
30
|
+
```
|
31
|
+
require 'rubygems'
|
32
|
+
require 'pwqgen'
|
21
33
|
|
22
|
-
|
23
|
-
|
24
|
-
- Within your application, `require "pwqgen"`.
|
34
|
+
p Pwqgen.generate # => "Image&Both-action"
|
35
|
+
p Pwqgen.generate 5 # => "Alaska_Union9Calf=domain&ever"
|
25
36
|
|
26
|
-
|
37
|
+
pgen = Pwqgen.new # => #<Pwqgen::Generator:0x9f6ec40 ...>
|
38
|
+
p pgen.generate # => "String5Rebel+horse"
|
39
|
+
p pgen.generate 2 # => "Easily2desist"
|
40
|
+
```
|
27
41
|
|
28
42
|
## Contributing
|
29
43
|
|
30
44
|
1. Fork it
|
31
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
2. Create your feature branch (`git checkout -b feature/my-new-feature`)
|
32
46
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
4. Push to the branch (`git push origin feature/my-new-feature`)
|
34
48
|
5. Create new Pull Request
|
35
49
|
|
50
|
+
## Related
|
51
|
+
|
52
|
+
- A web-based demonstration is available on [Heroku](https://pwqgen.herokuapp.com/). ([Source](https://github.com/iphoting/pwqgen-web)).
|
53
|
+
- Original C Implementation, <http://www.openwall.com/passwdqc/>.
|
54
|
+
|
55
|
+
## Credits
|
56
|
+
|
57
|
+
- Original Design and C implementation from <http://www.openwall.com/passwdqc/> by Solar Designer.
|
58
|
+
|
data/Rakefile
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
require 'rubygems'
|
2
3
|
require "bundler/gem_tasks"
|
3
4
|
require "rspec/core/rake_task"
|
5
|
+
require "cucumber"
|
6
|
+
require "cucumber/rake/task"
|
4
7
|
|
5
|
-
RSpec::Core::RakeTask.new
|
8
|
+
RSpec::Core::RakeTask.new do |spec|
|
9
|
+
spec.rspec_opts = ['-f d', '--color']
|
10
|
+
end
|
11
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
12
|
+
t.cucumber_opts = "features --format pretty"
|
13
|
+
end
|
6
14
|
|
7
|
-
task :default => :
|
8
|
-
task :test => :spec
|
15
|
+
task :default => :test
|
16
|
+
task :test => [:spec, :features]
|
9
17
|
|
data/bin/pwqgen.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
require 'pwqgen/version'
|
4
4
|
require 'pwqgen'
|
5
5
|
|
6
|
-
doc = "Usage: pwqgen.rb [options] <length>
|
6
|
+
doc = "Usage: pwqgen.rb [options] [<length>]
|
7
7
|
|
8
8
|
Options:
|
9
|
-
-h, --help
|
10
|
-
--version show version and exit
|
9
|
+
-h, --help show this help message and exit
|
10
|
+
-v, --version show version and exit
|
11
11
|
|
12
12
|
<length>: Number of words in the passphrase. [default: 3]
|
13
13
|
"
|
@@ -17,8 +17,8 @@ require 'docopt'
|
|
17
17
|
options = Docopt(doc, Pwqgen::VERSION)
|
18
18
|
|
19
19
|
if ARGV.length > 0 && ARGV[0].to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) then
|
20
|
-
|
20
|
+
puts Pwqgen.generate(ARGV[0].to_i)
|
21
21
|
else
|
22
|
-
|
22
|
+
puts Pwqgen.generate
|
23
23
|
end
|
24
24
|
|
data/doc/ChangeLog.html
CHANGED
@@ -53,6 +53,8 @@
|
|
53
53
|
|
54
54
|
<li class="file"><a href="./Gemfile.html">Gemfile</a>
|
55
55
|
|
56
|
+
<li class="file"><a href="./Rakefile.html">Rakefile</a>
|
57
|
+
|
56
58
|
</ul>
|
57
59
|
</nav>
|
58
60
|
|
@@ -73,6 +75,18 @@
|
|
73
75
|
|
74
76
|
<div id="documentation" class="description">
|
75
77
|
|
78
|
+
<h1 id="label-0.0.3+%2F+Unreleased">0.0.3 / Unreleased</h1>
|
79
|
+
|
80
|
+
<pre>* Improved CLI output.
|
81
|
+
* `Pwqgen.new` now works.
|
82
|
+
* Updated documentation with better usage examples.</pre>
|
83
|
+
|
84
|
+
<h1 id="label-0.0.2+%2F+2012-06-29">0.0.2 / 2012-06-29</h1>
|
85
|
+
|
86
|
+
<pre>* Added unit tests.
|
87
|
+
* Simplified invocation. You can now just call `Pwqgen.generate`.
|
88
|
+
* Fixed a bug where `pwqgen.rb` did not produce output.</pre>
|
89
|
+
|
76
90
|
<h1 id="label-0.0.1+%2F+2012-06-28">0.0.1 / 2012-06-28</h1>
|
77
91
|
|
78
92
|
<pre>* Initial release.</pre>
|
data/doc/Gemfile.html
CHANGED
@@ -53,6 +53,8 @@
|
|
53
53
|
|
54
54
|
<li class="file"><a href="./Gemfile.html">Gemfile</a>
|
55
55
|
|
56
|
+
<li class="file"><a href="./Rakefile.html">Rakefile</a>
|
57
|
+
|
56
58
|
</ul>
|
57
59
|
</nav>
|
58
60
|
|
@@ -73,9 +75,9 @@
|
|
73
75
|
|
74
76
|
<div id="documentation" class="description">
|
75
77
|
|
76
|
-
<p>source :rubygems
|
78
|
+
<p>source :rubygems</p>
|
77
79
|
|
78
|
-
<p>
|
80
|
+
<p>gemspec</p>
|
79
81
|
|
80
82
|
</div>
|
81
83
|
|
data/doc/Pwqgen.html
CHANGED
@@ -47,7 +47,6 @@
|
|
47
47
|
<nav id="file-list-section" class="section">
|
48
48
|
<h3 class="section-header">Defined In</h3>
|
49
49
|
<ul>
|
50
|
-
<li>lib/pwqgen.rb
|
51
50
|
<li>lib/pwqgen/pwqgen.rb
|
52
51
|
<li>lib/pwqgen/wordlist.rb
|
53
52
|
<li>lib/pwqgen/version.rb
|
@@ -61,7 +60,19 @@
|
|
61
60
|
|
62
61
|
|
63
62
|
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<nav id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
|
67
|
+
<ul class="link-list">
|
68
|
+
|
69
|
+
<li><a href="#method-c-generate">::generate</a>
|
64
70
|
|
71
|
+
<li><a href="#method-c-new">::new</a>
|
72
|
+
|
73
|
+
</ul>
|
74
|
+
</nav>
|
75
|
+
|
65
76
|
</div>
|
66
77
|
|
67
78
|
<div id="project-metadata">
|
@@ -74,6 +85,8 @@
|
|
74
85
|
|
75
86
|
<li class="file"><a href="./Gemfile.html">Gemfile</a>
|
76
87
|
|
88
|
+
<li class="file"><a href="./Rakefile.html">Rakefile</a>
|
89
|
+
|
77
90
|
</ul>
|
78
91
|
</nav>
|
79
92
|
|
@@ -100,13 +113,19 @@
|
|
100
113
|
<p>Public: <a href="Pwqgen.html">Pwqgen</a> is a Ruby implementation of
|
101
114
|
passwdqc’s pwqgen password generator.</p>
|
102
115
|
|
103
|
-
<p>
|
116
|
+
<p>Examples</p>
|
117
|
+
|
118
|
+
<pre class="ruby"><span class="ruby-constant">Pwqgen</span>.<span class="ruby-identifier">generate</span>
|
119
|
+
<span class="ruby-comment"># => "Unrest3Male!trout"</span>
|
104
120
|
|
105
|
-
<
|
106
|
-
<span class="ruby-comment"># => "
|
121
|
+
<span class="ruby-constant">Pwqgen</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">generate</span>
|
122
|
+
<span class="ruby-comment"># => "Obese6Perish6viola"</span>
|
107
123
|
|
108
|
-
<span class="ruby-constant">Pwqgen</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">generate</span>
|
109
|
-
<span class="ruby-comment"># => "
|
124
|
+
<span class="ruby-constant">Pwqgen</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">generate</span>
|
125
|
+
<span class="ruby-comment"># => "Crime2Behave=growth"</span>
|
126
|
+
|
127
|
+
<span class="ruby-constant">Pwqgen</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">generate</span> <span class="ruby-value">4</span>
|
128
|
+
<span class="ruby-comment"># => "Caesar-Madam7draft8choose"</span>
|
110
129
|
</pre>
|
111
130
|
|
112
131
|
<p>Private: Wordlist stolen from passwdqc’s wordset_4k.c. <a
|
@@ -204,6 +223,85 @@ that no word is shorter than 3 characters.</p>
|
|
204
223
|
|
205
224
|
<!-- Methods -->
|
206
225
|
|
226
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
227
|
+
<h3 class="section-header">Public Class Methods</h3>
|
228
|
+
|
229
|
+
|
230
|
+
<div id="method-c-generate" class="method-detail ">
|
231
|
+
|
232
|
+
<div class="method-heading">
|
233
|
+
<span class="method-name">generate</span><span
|
234
|
+
class="method-args">(length = 3)</span>
|
235
|
+
<span class="method-click-advice">click to toggle source</span>
|
236
|
+
</div>
|
237
|
+
|
238
|
+
|
239
|
+
<div class="method-description">
|
240
|
+
|
241
|
+
<p>Public: Returns a random generated password string.</p>
|
242
|
+
|
243
|
+
<p>length - number of words used to create the passphrase.</p>
|
244
|
+
|
245
|
+
<p>Example</p>
|
246
|
+
|
247
|
+
<pre class="ruby"><span class="ruby-constant">Pwqgen</span>.<span class="ruby-identifier">generate</span> <span class="ruby-value">2</span>
|
248
|
+
<span class="ruby-comment"># => "Loyal8atomic"</span>
|
249
|
+
|
250
|
+
<span class="ruby-constant">Pwqgen</span>.<span class="ruby-identifier">generate</span>
|
251
|
+
<span class="ruby-comment"># => "Gate*Abound&hull"</span>
|
252
|
+
</pre>
|
253
|
+
|
254
|
+
<p>Returns a password string.</p>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
<div class="method-source-code" id="generate-source">
|
259
|
+
<pre><span class="ruby-comment"># File lib/pwqgen/pwqgen.rb, line 35</span>
|
260
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">generate</span>(<span class="ruby-identifier">length</span> = <span class="ruby-value">3</span>)
|
261
|
+
<span class="ruby-keyword">self</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">generate</span> <span class="ruby-identifier">length</span>
|
262
|
+
<span class="ruby-keyword">end</span></pre>
|
263
|
+
</div><!-- generate-source -->
|
264
|
+
|
265
|
+
</div>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
</div><!-- generate-method -->
|
271
|
+
|
272
|
+
|
273
|
+
<div id="method-c-new" class="method-detail ">
|
274
|
+
|
275
|
+
<div class="method-heading">
|
276
|
+
<span class="method-name">new</span><span
|
277
|
+
class="method-args">()</span>
|
278
|
+
<span class="method-click-advice">click to toggle source</span>
|
279
|
+
</div>
|
280
|
+
|
281
|
+
|
282
|
+
<div class="method-description">
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
<div class="method-source-code" id="new-source">
|
289
|
+
<pre><span class="ruby-comment"># File lib/pwqgen/pwqgen.rb, line 39</span>
|
290
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">new</span>
|
291
|
+
<span class="ruby-keyword">self</span><span class="ruby-operator">::</span><span class="ruby-constant">Generator</span>.<span class="ruby-identifier">new</span>
|
292
|
+
<span class="ruby-keyword">end</span></pre>
|
293
|
+
</div><!-- new-source -->
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
</div><!-- new-method -->
|
301
|
+
|
302
|
+
|
303
|
+
</section><!-- public-class-method-details -->
|
304
|
+
|
207
305
|
</section><!-- 5Buntitled-5D -->
|
208
306
|
|
209
307
|
</div><!-- documentation -->
|
data/doc/Pwqgen/Generator.html
CHANGED
@@ -90,6 +90,8 @@
|
|
90
90
|
|
91
91
|
<li class="file"><a href="../Gemfile.html">Gemfile</a>
|
92
92
|
|
93
|
+
<li class="file"><a href="../Rakefile.html">Rakefile</a>
|
94
|
+
|
93
95
|
</ul>
|
94
96
|
</nav>
|
95
97
|
|
@@ -149,12 +151,11 @@
|
|
149
151
|
|
150
152
|
|
151
153
|
<div class="method-source-code" id="new-source">
|
152
|
-
<pre><span class="ruby-comment"># File lib/pwqgen/pwqgen.rb, line
|
154
|
+
<pre><span class="ruby-comment"># File lib/pwqgen/pwqgen.rb, line 44</span>
|
153
155
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>
|
154
156
|
<span class="ruby-identifier">@@wordlist_size</span> = <span class="ruby-identifier">@@wordlist</span>.<span class="ruby-identifier">length</span>
|
155
157
|
<span class="ruby-identifier">@@separators</span> = <span class="ruby-string">"-_!$&*+=23456789"</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">%r/</span>)
|
156
158
|
<span class="ruby-identifier">@@separators_size</span> = <span class="ruby-identifier">@@separators</span>.<span class="ruby-identifier">length</span>
|
157
|
-
<span class="ruby-ivar">@length</span> = <span class="ruby-value">3</span>
|
158
159
|
<span class="ruby-ivar">@rand</span> = <span class="ruby-constant">Random</span>.<span class="ruby-identifier">new</span>
|
159
160
|
<span class="ruby-keyword">end</span></pre>
|
160
161
|
</div><!-- new-source -->
|
@@ -177,20 +178,33 @@
|
|
177
178
|
|
178
179
|
<div class="method-heading">
|
179
180
|
<span class="method-name">generate</span><span
|
180
|
-
class="method-args">(length =
|
181
|
+
class="method-args">(length = 3)</span>
|
181
182
|
<span class="method-click-advice">click to toggle source</span>
|
182
183
|
</div>
|
183
184
|
|
184
185
|
|
185
186
|
<div class="method-description">
|
186
187
|
|
187
|
-
|
188
|
+
<p>Public: Returns a random generated password string.</p>
|
189
|
+
|
190
|
+
<p>length - number of words used to create the passphrase.</p>
|
191
|
+
|
192
|
+
<p>Example</p>
|
193
|
+
|
194
|
+
<pre class="ruby"><span class="ruby-identifier">generate</span> <span class="ruby-value">2</span>
|
195
|
+
<span class="ruby-comment"># => "Loyal8atomic"</span>
|
196
|
+
|
197
|
+
<span class="ruby-identifier">generate</span>
|
198
|
+
<span class="ruby-comment"># => "Gate*Abound&hull"</span>
|
199
|
+
</pre>
|
200
|
+
|
201
|
+
<p>Returns a password string.</p>
|
188
202
|
|
189
203
|
|
190
204
|
|
191
205
|
<div class="method-source-code" id="generate-source">
|
192
|
-
<pre><span class="ruby-comment"># File lib/pwqgen/pwqgen.rb, line
|
193
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">generate</span>(<span class="ruby-identifier">length</span> = <span class="ruby-
|
206
|
+
<pre><span class="ruby-comment"># File lib/pwqgen/pwqgen.rb, line 64</span>
|
207
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">generate</span>(<span class="ruby-identifier">length</span> = <span class="ruby-value">3</span>)
|
194
208
|
<span class="ruby-identifier">output</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
|
195
209
|
<span class="ruby-keyword">for</span> <span class="ruby-identifier">i</span> <span class="ruby-keyword">in</span> <span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">length</span>
|
196
210
|
<span class="ruby-identifier">output</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">@@wordlist</span>[<span class="ruby-ivar">@rand</span>.<span class="ruby-identifier">rand</span>(<span class="ruby-identifier">@@wordlist_size</span>)]
|
data/doc/Rakefile.html
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>Rakefile - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "./";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body class="file">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="./index.html">Home</a>
|
28
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
<div id="project-metadata">
|
47
|
+
<nav id="fileindex-section" class="section project-section">
|
48
|
+
<h3 class="section-header">Pages</h3>
|
49
|
+
|
50
|
+
<ul>
|
51
|
+
|
52
|
+
<li class="file"><a href="./ChangeLog.html">ChangeLog</a>
|
53
|
+
|
54
|
+
<li class="file"><a href="./Gemfile.html">Gemfile</a>
|
55
|
+
|
56
|
+
<li class="file"><a href="./Rakefile.html">Rakefile</a>
|
57
|
+
|
58
|
+
</ul>
|
59
|
+
</nav>
|
60
|
+
|
61
|
+
<nav id="classindex-section" class="section project-section">
|
62
|
+
<h3 class="section-header">Class and Module Index</h3>
|
63
|
+
|
64
|
+
<ul class="link-list">
|
65
|
+
|
66
|
+
<li><a href="./Pwqgen.html">Pwqgen</a>
|
67
|
+
|
68
|
+
<li><a href="./Pwqgen/Generator.html">Pwqgen::Generator</a>
|
69
|
+
|
70
|
+
</ul>
|
71
|
+
</nav>
|
72
|
+
|
73
|
+
</div>
|
74
|
+
</nav>
|
75
|
+
|
76
|
+
<div id="documentation" class="description">
|
77
|
+
|
78
|
+
<p>#!/usr/bin/env rake require “bundler/gem_tasks” require
|
79
|
+
“rspec/core/rake_task”</p>
|
80
|
+
|
81
|
+
<p>RSpec::Core::RakeTask.new</p>
|
82
|
+
|
83
|
+
<p>task :default => :spec task :test => :spec</p>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<footer id="validator-badges">
|
90
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
91
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
|
92
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
93
|
+
</footer>
|
94
|
+
|
data/doc/created.rid
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
2
|
-
./bin/pwqgen.rb
|
3
|
-
./lib/pwqgen.rb
|
4
|
-
./lib/pwqgen/pwqgen.rb
|
5
|
-
./lib/pwqgen/wordlist.rb
|
6
|
-
./lib/pwqgen/version.rb
|
7
|
-
./
|
8
|
-
./
|
1
|
+
Fri, 29 Jun 2012 16:02:55 +0800
|
2
|
+
./bin/pwqgen.rb Fri, 29 Jun 2012 11:49:44 +0800
|
3
|
+
./lib/pwqgen.rb Fri, 29 Jun 2012 01:05:28 +0800
|
4
|
+
./lib/pwqgen/pwqgen.rb Fri, 29 Jun 2012 15:48:25 +0800
|
5
|
+
./lib/pwqgen/wordlist.rb Fri, 29 Jun 2012 01:05:28 +0800
|
6
|
+
./lib/pwqgen/version.rb Fri, 29 Jun 2012 11:09:21 +0800
|
7
|
+
./spec/lib/pwqgen_spec.rb Fri, 29 Jun 2012 15:53:29 +0800
|
8
|
+
./spec/spec_helper.rb Fri, 29 Jun 2012 01:05:28 +0800
|
9
|
+
./Rakefile Fri, 29 Jun 2012 01:05:28 +0800
|
10
|
+
./Gemfile Fri, 29 Jun 2012 01:05:28 +0800
|
11
|
+
./ChangeLog Fri, 29 Jun 2012 15:28:04 +0800
|
data/doc/index.html
CHANGED
data/doc/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["pwqgen","generator","generate()","new()","changelog","gemfile"],"longSearchIndex":["pwqgen","pwqgen::generator","pwqgen::generator#generate()","pwqgen::generator::new()","",""],"info":[["Pwqgen","","Pwqgen.html","","<p>Public: Pwqgen is a Ruby implementation of passwdqc’s pwqgen password\ngenerator.\n<p>
|
1
|
+
var search_data = {"index":{"searchIndex":["pwqgen","generator","generate()","generate()","new()","new()","changelog","gemfile","rakefile"],"longSearchIndex":["pwqgen","pwqgen::generator","pwqgen::generate()","pwqgen::generator#generate()","pwqgen::new()","pwqgen::generator::new()","","",""],"info":[["Pwqgen","","Pwqgen.html","","<p>Public: Pwqgen is a Ruby implementation of passwdqc’s pwqgen password\ngenerator.\n<p>Examples\n\n<pre>Pwqgen.generate ...</pre>\n"],["Pwqgen::Generator","","Pwqgen/Generator.html","",""],["generate","Pwqgen","Pwqgen.html#method-c-generate","(length = 3)","<p>Public: Returns a random generated password string.\n<p>length - number of words used to create the passphrase. …\n"],["generate","Pwqgen::Generator","Pwqgen/Generator.html#method-i-generate","(length = 3)","<p>Public: Returns a random generated password string.\n<p>length - number of words used to create the passphrase. …\n"],["new","Pwqgen","Pwqgen.html#method-c-new","()",""],["new","Pwqgen::Generator","Pwqgen/Generator.html#method-c-new","()",""],["ChangeLog","","ChangeLog.html","","<p>0.0.3 / Unreleased\n\n<pre>* Improved CLI output.\n* `Pwqgen.new` now works.\n* Updated documentation with better ...</pre>\n"],["Gemfile","","Gemfile.html","","<p>source :rubygems\n<p>gemspec\n"],["Rakefile","","Rakefile.html","","<p>#!/usr/bin/env rake require “bundler/gem_tasks” require\n“rspec/core/rake_task”\n<p>RSpec::Core::RakeTask.new …\n"]]}}
|
data/doc/table_of_contents.html
CHANGED
@@ -30,12 +30,17 @@
|
|
30
30
|
|
31
31
|
<img class="toc-toggle" src="images/transparent.png" alt="" title="toggle headings">
|
32
32
|
<ul class="initially-hidden">
|
33
|
+
<li><a href="ChangeLog.html#label-0.0.3+%2F+Unreleased">0.0.3 / Unreleased</a>
|
34
|
+
<li><a href="ChangeLog.html#label-0.0.2+%2F+2012-06-29">0.0.2 / 2012-06-29</a>
|
33
35
|
<li><a href="ChangeLog.html#label-0.0.1+%2F+2012-06-28">0.0.1 / 2012-06-28</a>
|
34
36
|
</ul>
|
35
37
|
</li>
|
36
38
|
<li class="file">
|
37
39
|
<a href="Gemfile.html">Gemfile</a>
|
38
40
|
</li>
|
41
|
+
<li class="file">
|
42
|
+
<a href="Rakefile.html">Rakefile</a>
|
43
|
+
</li>
|
39
44
|
|
40
45
|
</ul>
|
41
46
|
|
@@ -53,8 +58,12 @@
|
|
53
58
|
<h2 id="methods">Methods</h2>
|
54
59
|
<ul>
|
55
60
|
|
61
|
+
<li class="method"><a href="Pwqgen.html#method-c-generate">::generate — Pwqgen</a>
|
62
|
+
|
56
63
|
<li class="method"><a href="Pwqgen/Generator.html#method-c-new">::new — Pwqgen::Generator</a>
|
57
64
|
|
65
|
+
<li class="method"><a href="Pwqgen.html#method-c-new">::new — Pwqgen</a>
|
66
|
+
|
58
67
|
<li class="method"><a href="Pwqgen/Generator.html#method-i-generate">#generate — Pwqgen::Generator</a>
|
59
68
|
|
60
69
|
</ul>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
@announce-cmd
|
2
|
+
@posix
|
3
|
+
Feature: Password Generation
|
4
|
+
|
5
|
+
In order to use a secure password for my login
|
6
|
+
As an end user
|
7
|
+
I want to get a strong randomly generated password
|
8
|
+
|
9
|
+
Scenario: Generate a random password of default length
|
10
|
+
When I run `pwqgen.rb`
|
11
|
+
Then the output should match /^[A-Za-z]{3,6}([-_!$&*+=23456789][A-Za-z]{3,6}){2}$/
|
12
|
+
|
13
|
+
Scenario: Generate a random password of length 2
|
14
|
+
When I run `pwqgen.rb 2`
|
15
|
+
Then the output should match /^[A-Za-z]{3,6}([-_!$&*+=23456789][A-Za-z]{3,6}){1}$/
|
16
|
+
|
17
|
+
Scenario: Generate a random password of length 5
|
18
|
+
When I run `pwqgen.rb 5`
|
19
|
+
Then the output should match /^[A-Za-z]{3,6}([-_!$&*+=23456789][A-Za-z]{3,6}){4}$/
|
20
|
+
|
21
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
+
require 'aruba/cucumber'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'rspec/expectations'
|
5
|
+
|
6
|
+
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
|
7
|
+
|
8
|
+
Before do
|
9
|
+
if RUBY_PLATFORM =~ /java/
|
10
|
+
# ideas taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html
|
11
|
+
set_env('JRUBY_OPTS', '-X-C') # disable JIT since these processes are so short lived
|
12
|
+
set_env('JAVA_OPTS', '-d32') # force jRuby to use client JVM for faster startup times
|
13
|
+
@aruba_timeout_seconds = 60
|
14
|
+
else
|
15
|
+
@aruba_timeout_seconds = 5
|
16
|
+
end
|
17
|
+
end
|
data/lib/pwqgen/pwqgen.rb
CHANGED
@@ -3,7 +3,13 @@ require 'pwqgen/wordlist'
|
|
3
3
|
# Public: Pwqgen is a Ruby implementation of passwdqc's pwqgen password
|
4
4
|
# generator.
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# Examples
|
7
|
+
#
|
8
|
+
# Pwqgen.generate
|
9
|
+
# # => "Unrest3Male!trout"
|
10
|
+
#
|
11
|
+
# Pwqgen.new.generate
|
12
|
+
# # => "Obese6Perish6viola"
|
7
13
|
#
|
8
14
|
# Pwqgen::Generator.new.generate
|
9
15
|
# # => "Crime2Behave=growth"
|
@@ -13,10 +19,27 @@ require 'pwqgen/wordlist'
|
|
13
19
|
#
|
14
20
|
module Pwqgen
|
15
21
|
|
22
|
+
# Public: Returns a random generated password string.
|
23
|
+
#
|
24
|
+
# length - number of words used to create the passphrase.
|
25
|
+
#
|
26
|
+
# Example
|
27
|
+
#
|
28
|
+
# Pwqgen.generate 2
|
29
|
+
# # => "Loyal8atomic"
|
30
|
+
#
|
31
|
+
# Pwqgen.generate
|
32
|
+
# # => "Gate*Abound&hull"
|
33
|
+
#
|
34
|
+
# Returns a password string.
|
16
35
|
def self.generate(length = 3)
|
17
36
|
self::Generator.new.generate length
|
18
37
|
end
|
19
38
|
|
39
|
+
def self.new
|
40
|
+
self::Generator.new
|
41
|
+
end
|
42
|
+
|
20
43
|
class Generator
|
21
44
|
def initialize
|
22
45
|
@@wordlist_size = @@wordlist.length
|
@@ -25,6 +48,19 @@ module Pwqgen
|
|
25
48
|
@rand = Random.new
|
26
49
|
end
|
27
50
|
|
51
|
+
# Public: Returns a random generated password string.
|
52
|
+
#
|
53
|
+
# length - number of words used to create the passphrase.
|
54
|
+
#
|
55
|
+
# Example
|
56
|
+
#
|
57
|
+
# generate 2
|
58
|
+
# # => "Loyal8atomic"
|
59
|
+
#
|
60
|
+
# generate
|
61
|
+
# # => "Gate*Abound&hull"
|
62
|
+
#
|
63
|
+
# Returns a password string.
|
28
64
|
def generate(length = 3)
|
29
65
|
output = Array.new
|
30
66
|
for i in 1..length
|
data/lib/pwqgen/version.rb
CHANGED
data/pwqgen.rb.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = 'pwqgen.rb'
|
7
7
|
s.version = Pwqgen::VERSION
|
8
8
|
s.summary = "pwqgen in Ruby"
|
9
|
-
s.description = "pwqgen.rb
|
9
|
+
s.description = "pwqgen.rb is a Ruby implementation of passwdqc's pwqgen, a random pronouncable password generator."
|
10
10
|
s.authors = ["Ronald Ip"]
|
11
11
|
s.email = 'myself@iphoting.com'
|
12
12
|
s.homepage = 'https://github.com/iphoting/pwqgen.rb'
|
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_development_dependency 'rake'
|
23
23
|
s.add_development_dependency 'rspec'
|
24
|
+
s.add_development_dependency 'aruba'
|
24
25
|
end
|
data/spec/lib/pwqgen_spec.rb
CHANGED
@@ -24,4 +24,36 @@ describe Pwqgen do
|
|
24
24
|
password.should be_kind_of(String)
|
25
25
|
password.length.should be_within(8).of(27)
|
26
26
|
end
|
27
|
+
|
28
|
+
it "should return a Pwqgen::Generator object when Pwqgen.new is called" do
|
29
|
+
obj = Pwqgen.new
|
30
|
+
obj.should_not be_nil
|
31
|
+
obj.should be_an_instance_of(Pwqgen::Generator)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe Pwqgen::Generator do
|
36
|
+
it "should return a random password" do
|
37
|
+
password = Pwqgen::Generator.new.generate
|
38
|
+
password.should_not be_nil
|
39
|
+
password.should_not be_empty
|
40
|
+
password.should be_kind_of(String)
|
41
|
+
password.length.should be_within(5).of(15)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return a short random password when given a length of 1" do
|
45
|
+
password = Pwqgen::Generator.new.generate 1
|
46
|
+
password.should_not be_nil
|
47
|
+
password.should_not be_empty
|
48
|
+
password.should be_kind_of(String)
|
49
|
+
password.length.should be_within(2).of(4)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should return a longer random password when given a length of 5" do
|
53
|
+
password = Pwqgen::Generator.new.generate 5
|
54
|
+
password.should_not be_nil
|
55
|
+
password.should_not be_empty
|
56
|
+
password.should be_kind_of(String)
|
57
|
+
password.length.should be_within(8).of(27)
|
58
|
+
end
|
27
59
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwqgen.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ronald Ip
|
@@ -59,7 +59,24 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: aruba
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: pwqgen.rb is a Ruby implementation of passwdqc's pwqgen, a random pronouncable
|
79
|
+
password generator.
|
63
80
|
email: myself@iphoting.com
|
64
81
|
executables:
|
65
82
|
- pwqgen.rb
|
@@ -77,6 +94,7 @@ files:
|
|
77
94
|
- doc/Gemfile.html
|
78
95
|
- doc/Pwqgen.html
|
79
96
|
- doc/Pwqgen/Generator.html
|
97
|
+
- doc/Rakefile.html
|
80
98
|
- doc/created.rid
|
81
99
|
- doc/images/add.png
|
82
100
|
- doc/images/brick.png
|
@@ -111,6 +129,9 @@ files:
|
|
111
129
|
- doc/js/searcher.js
|
112
130
|
- doc/rdoc.css
|
113
131
|
- doc/table_of_contents.html
|
132
|
+
- features/password_generation.feature
|
133
|
+
- features/step_definitions/pwqgen.rb_steps.rb
|
134
|
+
- features/support/env.rb
|
114
135
|
- lib/pwqgen.rb
|
115
136
|
- lib/pwqgen/pwqgen.rb
|
116
137
|
- lib/pwqgen/version.rb
|
@@ -133,9 +154,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
155
|
none: false
|
135
156
|
requirements:
|
136
|
-
- - ! '
|
157
|
+
- - ! '>'
|
137
158
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
159
|
+
version: 1.3.1
|
139
160
|
requirements: []
|
140
161
|
rubyforge_project:
|
141
162
|
rubygems_version: 1.8.23
|
@@ -143,6 +164,9 @@ signing_key:
|
|
143
164
|
specification_version: 3
|
144
165
|
summary: pwqgen in Ruby
|
145
166
|
test_files:
|
167
|
+
- features/password_generation.feature
|
168
|
+
- features/step_definitions/pwqgen.rb_steps.rb
|
169
|
+
- features/support/env.rb
|
146
170
|
- spec/lib/pwqgen_spec.rb
|
147
171
|
- spec/spec_helper.rb
|
148
172
|
has_rdoc:
|