dgen 0.1.0 → 0.2.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 +4 -4
- data/lib/dgen/base.rb +54 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d401a5a3ae4f5f7e38d9374c5071a40b2cceecd5
|
4
|
+
data.tar.gz: 0713c03b735403a7ec8ab427f17060cd0a70878a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82423d35a7d6d82d9c54cf172ed83e6bce7d18db74299213c3740264ab59cfa6d5e832548ee18b472b6b136e78a7fa2b43a65687cf0fc382977ae9f30dbe6645
|
7
|
+
data.tar.gz: 87263cb6ecf3b9b48a813e458d2426aad08908a818bac43906d63c8aa2d479fdbd19b85016b23e4b6281b42ea503690704b5f43c7ce982e7f2ebfcbc02f873aa
|
data/lib/dgen/base.rb
CHANGED
@@ -1,17 +1,57 @@
|
|
1
|
-
#
|
1
|
+
# == Synopsis
|
2
|
+
#
|
3
|
+
# dgen: generates diceware passphrases
|
4
|
+
#
|
5
|
+
#
|
6
|
+
# == Usage
|
7
|
+
#
|
8
|
+
# dgen [OPTIONS]
|
9
|
+
#
|
10
|
+
# -h, --help:
|
11
|
+
# show help
|
12
|
+
#
|
13
|
+
# -i, --interactive:
|
14
|
+
# use the interactive menu to generate passphrases
|
15
|
+
#
|
2
16
|
# Copyright 2015 Richard Davis GPL v3
|
17
|
+
require 'optparse'
|
3
18
|
require 'dgen/passgen'
|
4
19
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
puts "Passphrase
|
17
|
-
|
20
|
+
def interactive
|
21
|
+
print 'Number of words for phrase (recommended minimum is 6 words) => '
|
22
|
+
n_words = gets.chomp.to_i
|
23
|
+
print 'Length of passphrase (recommended minimum is 17 characters) => '
|
24
|
+
p_length = gets.chomp.to_i
|
25
|
+
path = File.expand_path(File.join(File.dirname(__FILE__),
|
26
|
+
'..',
|
27
|
+
'assets',
|
28
|
+
'word-list.txt'))
|
29
|
+
f = File.new(path, 'r')
|
30
|
+
phrase = PassGen.new.generate_phrase(n_words, p_length, f)
|
31
|
+
puts "Passphrase with spaces: '#{phrase}'"
|
32
|
+
puts "Passphrase without spaces: '#{phrase.delete(' ')}'"
|
33
|
+
f.close
|
34
|
+
end
|
35
|
+
|
36
|
+
options = {}
|
37
|
+
|
38
|
+
optparse = OptionParser.new do |opts|
|
39
|
+
opts.banner = 'Usage: dgen [options]'
|
40
|
+
|
41
|
+
opts.on('-i', '--interactive', 'Manually enter constraints') do
|
42
|
+
options[:interactive] = true
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on('-h', '--help', 'Display this screen') do
|
46
|
+
puts opts
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
optparse.parse!
|
52
|
+
|
53
|
+
if options[:interactive]
|
54
|
+
interactive
|
55
|
+
else
|
56
|
+
puts 'You did not enter a valid option. Try --help.'
|
57
|
+
end
|