passphrase 0.0.3 → 0.1.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.
- data/README.rdoc +17 -15
- data/VERSION +1 -1
- data/bin/passphrase +0 -0
- data/lib/passphrase/generator.rb +1 -0
- data/lib/passphrase/options.rb +5 -0
- data/lib/passphrase/random.rb +21 -7
- data/lib/passphrase/version.rb +2 -2
- metadata +19 -17
data/README.rdoc
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
Trying to come up with a good passphrase when creating an SSH public key pair
|
4
4
|
or when signing up for an online service is a pain. Typical password generators
|
5
|
-
yield a string of random characters which
|
6
|
-
{Diceware method}[http://world.std.com/~reinhold/diceware.html]
|
7
|
-
passphrase made up of more-or-less recognizable words. This makes
|
8
|
-
type, while still being reasonably secure.
|
9
|
-
written in Ruby for generating a passphrase using the Diceware
|
5
|
+
yield a string of random characters which may be strong but is often hard to
|
6
|
+
type. The {Diceware method}[http://world.std.com/~reinhold/diceware.html]
|
7
|
+
constructs a passphrase made up of more-or-less recognizable words. This makes
|
8
|
+
it easier to type, while still being reasonably secure. Passphrase is a command
|
9
|
+
line tool written in Ruby for generating a passphrase using the Diceware
|
10
|
+
method.
|
10
11
|
|
11
12
|
The act of rolling dice is simulated by requesting random numbers from
|
12
13
|
{www.random.org}[http://www.random.org]. If a network error occurs or a request
|
@@ -19,24 +20,25 @@ code as compressed, base64 encoded strings. No external files are referenced.
|
|
19
20
|
|
20
21
|
== Generating a passphrase
|
21
22
|
|
22
|
-
The command line interface is simple. You have the option to
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
The command line interface is simple. You have the option to request from 3 to
|
24
|
+
10 words in the generated passphrase. The default is 5 if a number is not
|
25
|
+
specified. In addition, at least one capital letter, one number character, and
|
26
|
+
one non-alphanumeric character are automatically mixed into the passphrase.
|
27
|
+
However, you can omit mixing if desired.
|
26
28
|
|
27
29
|
Usage: passphrase [options]
|
28
30
|
Options:
|
29
31
|
-n, --num-words NUMBER Desired number of words (3..10), default 5
|
30
|
-
-x, --[no-]mix Mix in
|
31
|
-
-
|
32
|
-
-
|
32
|
+
-x, --[no-]mix Mix in cap, num, non-alphanum, default mix
|
33
|
+
-l, --local Force use of local random number generator
|
34
|
+
-h, --help Show this message and exit
|
35
|
+
-v, --version Show version and exit
|
33
36
|
|
34
37
|
== Examples
|
35
38
|
|
36
39
|
$ passphrase --num-words 3
|
37
|
-
unmixed phrase =>
|
38
|
-
|
39
|
-
passphrase => shot e!m mild
|
40
|
+
unmixed phrase => tomb sima smog
|
41
|
+
passphrase => ]omb s0ma smoG
|
40
42
|
|
41
43
|
$ passphrase --num-words 4 --no-mix
|
42
44
|
passphrase => humus smooth persia mz
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/bin/passphrase
CHANGED
File without changes
|
data/lib/passphrase/generator.rb
CHANGED
data/lib/passphrase/options.rb
CHANGED
@@ -11,10 +11,12 @@ module Passphrase
|
|
11
11
|
|
12
12
|
attr_reader :num_words
|
13
13
|
attr_reader :mix
|
14
|
+
attr_reader :local
|
14
15
|
|
15
16
|
def initialize(argv)
|
16
17
|
@num_words = DEFAULT_NUM_WORDS
|
17
18
|
@mix = true
|
19
|
+
@local = false
|
18
20
|
parse(argv)
|
19
21
|
validate
|
20
22
|
end
|
@@ -32,6 +34,9 @@ module Passphrase
|
|
32
34
|
opts.on("-x", "--[no-]mix", "Mix in cap, num, non-alphanum, default mix") do |m|
|
33
35
|
@mix = m
|
34
36
|
end
|
37
|
+
opts.on("-l", "--local", "Force use of local random number generator") do |l|
|
38
|
+
@local = l
|
39
|
+
end
|
35
40
|
opts.on_tail("-h", "--help", "Show this message and exit") do
|
36
41
|
puts opts
|
37
42
|
exit
|
data/lib/passphrase/random.rb
CHANGED
@@ -6,9 +6,12 @@ require 'securerandom'
|
|
6
6
|
module Passphrase
|
7
7
|
class Random
|
8
8
|
|
9
|
+
@@use_random_org = true
|
10
|
+
|
9
11
|
def initialize(num, min, max)
|
10
12
|
@num, @min, @max = num, min, max
|
11
13
|
@array_of_rands = []
|
14
|
+
@via_random_org = true
|
12
15
|
generate_array_of_rands
|
13
16
|
end
|
14
17
|
|
@@ -19,18 +22,29 @@ module Passphrase
|
|
19
22
|
def to_array
|
20
23
|
@array_of_rands
|
21
24
|
end
|
25
|
+
|
26
|
+
def self.use_local
|
27
|
+
@@use_random_org = false
|
28
|
+
end
|
22
29
|
|
23
30
|
private
|
24
31
|
|
25
32
|
def generate_array_of_rands
|
26
|
-
|
27
|
-
"&
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
if @@use_random_org
|
34
|
+
query = "/integers/?col=1&base=10&format=plain&rnd=new" +
|
35
|
+
"&num=#{@num}&min=#{@min}&max=#{@max}"
|
36
|
+
site = Net::HTTP.new("www.random.org")
|
37
|
+
response, data = site.get(query)
|
38
|
+
raise unless response.code == "200"
|
39
|
+
@array_of_rands = data.split.collect {|num| num.to_i}
|
40
|
+
else
|
41
|
+
local_rands
|
42
|
+
end
|
33
43
|
rescue
|
44
|
+
local_rands
|
45
|
+
end
|
46
|
+
|
47
|
+
def local_rands
|
34
48
|
max = @max - @min + 1
|
35
49
|
offset = @min
|
36
50
|
@num.times do
|
data/lib/passphrase/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: passphrase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Edmund Sumbar
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-04-25 00:00:00 -06:00
|
14
14
|
default_executable: passphrase
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -40,11 +40,12 @@ description: |+
|
|
40
40
|
|
41
41
|
Trying to come up with a good passphrase when creating an SSH public key pair
|
42
42
|
or when signing up for an online service is a pain. Typical password generators
|
43
|
-
yield a string of random characters which
|
44
|
-
{Diceware method}[http://world.std.com/~reinhold/diceware.html]
|
45
|
-
passphrase made up of more-or-less recognizable words. This makes
|
46
|
-
type, while still being reasonably secure.
|
47
|
-
written in Ruby for generating a passphrase using the Diceware
|
43
|
+
yield a string of random characters which may be strong but is often hard to
|
44
|
+
type. The {Diceware method}[http://world.std.com/~reinhold/diceware.html]
|
45
|
+
constructs a passphrase made up of more-or-less recognizable words. This makes
|
46
|
+
it easier to type, while still being reasonably secure. Passphrase is a command
|
47
|
+
line tool written in Ruby for generating a passphrase using the Diceware
|
48
|
+
method.
|
48
49
|
|
49
50
|
The act of rolling dice is simulated by requesting random numbers from
|
50
51
|
{www.random.org}[http://www.random.org]. If a network error occurs or a request
|
@@ -57,24 +58,25 @@ description: |+
|
|
57
58
|
|
58
59
|
== Generating a passphrase
|
59
60
|
|
60
|
-
The command line interface is simple. You have the option to
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
The command line interface is simple. You have the option to request from 3 to
|
62
|
+
10 words in the generated passphrase. The default is 5 if a number is not
|
63
|
+
specified. In addition, at least one capital letter, one number character, and
|
64
|
+
one non-alphanumeric character are automatically mixed into the passphrase.
|
65
|
+
However, you can omit mixing if desired.
|
64
66
|
|
65
67
|
Usage: passphrase [options]
|
66
68
|
Options:
|
67
69
|
-n, --num-words NUMBER Desired number of words (3..10), default 5
|
68
|
-
-x, --[no-]mix Mix in
|
69
|
-
-
|
70
|
-
-
|
70
|
+
-x, --[no-]mix Mix in cap, num, non-alphanum, default mix
|
71
|
+
-l, --local Force use of local random number generator
|
72
|
+
-h, --help Show this message and exit
|
73
|
+
-v, --version Show version and exit
|
71
74
|
|
72
75
|
== Examples
|
73
76
|
|
74
77
|
$ passphrase --num-words 3
|
75
|
-
unmixed phrase =>
|
76
|
-
|
77
|
-
passphrase => shot e!m mild
|
78
|
+
unmixed phrase => tomb sima smog
|
79
|
+
passphrase => ]omb s0ma smoG
|
78
80
|
|
79
81
|
$ passphrase --num-words 4 --no-mix
|
80
82
|
passphrase => humus smooth persia mz
|