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 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 is secure but is hard to type. The
6
- {Diceware method}[http://world.std.com/~reinhold/diceware.html] constructs a
7
- passphrase made up of more-or-less recognizable words. This makes it easier to
8
- type, while still being reasonably secure. Passphrase is a command line tool
9
- written in Ruby for generating a passphrase using the Diceware method.
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 specify the number
23
- of words in the generated passphrase within the range of 3 to 10. The default
24
- is 5. One _odd_ character is automatically mixed into one of the words
25
- comprising the passphrase. You can omit mixing if desired.
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 odd character, default mix
31
- -h, --help Show this message
32
- -v, --version Show version
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 => shot elm mild
38
- odd character => !
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.2
1
+ 0.0.3
data/bin/passphrase CHANGED
File without changes
@@ -16,6 +16,7 @@ module Passphrase
16
16
  def initialize(argv)
17
17
  @options = Options.new(argv)
18
18
  @words = []
19
+ Random.use_local if @options.local
19
20
  end
20
21
 
21
22
  def run
@@ -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
@@ -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
- query = "/integers/?col=1&base=10&format=plain&rnd=new" +
27
- "&num=#{@num}&min=#{@min}&max=#{@max}"
28
- site = Net::HTTP.new("www.random.org")
29
- response, data = site.get(query)
30
- raise unless response.code == "200"
31
- @array_of_rands = data.split.collect {|num| num.to_i}
32
- @via_random_org = true
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
@@ -6,8 +6,8 @@ module Passphrase
6
6
  # rubygems rational versioning policy
7
7
  # http://docs.rubygems.org/read/chapter/7
8
8
  MAJOR = 0
9
- MINOR = 0
10
- BUILD = 3
9
+ MINOR = 1
10
+ BUILD = 0
11
11
 
12
12
  STRING = [MAJOR, MINOR, BUILD].compact.join('.')
13
13
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: passphrase
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
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-03-12 00:00:00 -07:00
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 is secure but is hard to type. The
44
- {Diceware method}[http://world.std.com/~reinhold/diceware.html] constructs a
45
- passphrase made up of more-or-less recognizable words. This makes it easier to
46
- type, while still being reasonably secure. Passphrase is a command line tool
47
- written in Ruby for generating a passphrase using the Diceware method.
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 specify the number
61
- of words in the generated passphrase within the range of 3 to 10. The default
62
- is 5. One _odd_ character is automatically mixed into one of the words
63
- comprising the passphrase. You can omit mixing if desired.
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 odd character, default mix
69
- -h, --help Show this message
70
- -v, --version Show version
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 => shot elm mild
76
- odd character => !
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