dgen 0.4.0 → 0.5.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 +5 -5
- data/lib/dgen.rb +27 -0
- data/lib/dgen/base.rb +59 -13
- data/lib/dgen/diceware.rb +71 -0
- data/lib/dgen/outputfile.rb +64 -60
- data/lib/dgen/passgen.rb +53 -77
- data/test/assets/word-list.txt +7776 -0
- data/test/test_diceware.rb +61 -0
- data/test/test_passgen.rb +50 -0
- metadata +15 -11
- data/test/test_dgen.rb +0 -29
@@ -0,0 +1,61 @@
|
|
1
|
+
# Copyright 2015-2018 Richard Davis
|
2
|
+
#
|
3
|
+
# This file is part of dgen.
|
4
|
+
#
|
5
|
+
# dgen is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# dgen is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with dgen. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'test/unit'
|
19
|
+
require 'dgen/diceware'
|
20
|
+
|
21
|
+
##
|
22
|
+
# = DicewareTest
|
23
|
+
# Author:: Dick Davis
|
24
|
+
# Copyright:: Copyright 2015-2018 Dick Davis
|
25
|
+
# License:: GNU Public License 3
|
26
|
+
#
|
27
|
+
# Tests the Diceware module.
|
28
|
+
class DicewareTest < Test::Unit::TestCase
|
29
|
+
##
|
30
|
+
# Sets variables required for testing.
|
31
|
+
def setup
|
32
|
+
@n_words = 6
|
33
|
+
@n_chars = 17
|
34
|
+
path = File.expand_path(File.join(File.dirname(__FILE__),
|
35
|
+
'..',
|
36
|
+
'test/assets',
|
37
|
+
'word-list.txt'))
|
38
|
+
@word_list = File.new(path, 'r')
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Tests generating numbers for selecting random words.
|
43
|
+
def test_roll_nums
|
44
|
+
assert_match(/^\d{5}$/, Dgen::Diceware.roll_nums)
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Tests finding words from wordlist given a number.
|
49
|
+
def test_find_word
|
50
|
+
num = '11111'
|
51
|
+
assert_equal(Dgen::Diceware.find_word(num, @word_list), 'a')
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Tests making a phrase with selected words.
|
56
|
+
def test_make_phrase
|
57
|
+
assert_match(/\w||\s{17,}/, Dgen::Diceware.make_phrase(@n_words,
|
58
|
+
@n_chars,
|
59
|
+
@word_list))
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright 2015-2018 Richard Davis
|
2
|
+
#
|
3
|
+
# This file is part of dgen.
|
4
|
+
#
|
5
|
+
# dgen is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# dgen is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with dgen. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'test/unit'
|
19
|
+
require 'dgen/passgen'
|
20
|
+
|
21
|
+
##
|
22
|
+
# = PassGenTest
|
23
|
+
# Author:: Dick Davis
|
24
|
+
# Copyright:: Copyright 2015-2018 Dick Davis
|
25
|
+
# License:: GNU Public License 3
|
26
|
+
#
|
27
|
+
# Tests the Dgen::PassGen class.
|
28
|
+
class PassGenTest < Test::Unit::TestCase
|
29
|
+
##
|
30
|
+
# Instantiates a Dgen::PassGen instance for testing.
|
31
|
+
def setup
|
32
|
+
@generator = Dgen::PassGen.new(6, 17)
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Tests generation of a single passphrase.
|
37
|
+
def test_single
|
38
|
+
assert_match(/\w||\s{17,}/, @generator.single)
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Tests generation of multiple passphrases.
|
43
|
+
def test_batch
|
44
|
+
passphrases = @generator.batch(3)
|
45
|
+
assert_equal(3, passphrases.length)
|
46
|
+
assert_match(/\w||\s{17,}/, passphrases[0])
|
47
|
+
assert_match(/\w||\s{17,}/, passphrases[1])
|
48
|
+
assert_match(/\w||\s{17,}/, passphrases[2])
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: crypt
|
@@ -30,11 +30,10 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.2.1
|
33
|
-
description:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
email: dick@sbdsec.com
|
33
|
+
description: Using the diceware method to generate passwords results in stronger passwords
|
34
|
+
that are more resistant to cracking. This project implements the diceware method
|
35
|
+
to create passphrases that are strong and easy to remember.
|
36
|
+
email: dick@rvdavis.me
|
38
37
|
executables:
|
39
38
|
- dgen
|
40
39
|
extensions: []
|
@@ -44,12 +43,15 @@ files:
|
|
44
43
|
- lib/assets/word-list.txt
|
45
44
|
- lib/dgen.rb
|
46
45
|
- lib/dgen/base.rb
|
46
|
+
- lib/dgen/diceware.rb
|
47
47
|
- lib/dgen/outputfile.rb
|
48
48
|
- lib/dgen/passgen.rb
|
49
|
-
- test/
|
49
|
+
- test/assets/word-list.txt
|
50
|
+
- test/test_diceware.rb
|
51
|
+
- test/test_passgen.rb
|
50
52
|
homepage: https://github.com/d3d1rty/dgen
|
51
53
|
licenses:
|
52
|
-
- GPL
|
54
|
+
- GPL-3
|
53
55
|
metadata: {}
|
54
56
|
post_install_message:
|
55
57
|
rdoc_options: []
|
@@ -67,9 +69,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
69
|
version: '0'
|
68
70
|
requirements: []
|
69
71
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
72
|
+
rubygems_version: 2.7.6
|
71
73
|
signing_key:
|
72
74
|
specification_version: 4
|
73
75
|
summary: A simple diceware password generator
|
74
76
|
test_files:
|
75
|
-
- test/
|
77
|
+
- test/test_passgen.rb
|
78
|
+
- test/test_diceware.rb
|
79
|
+
- test/assets/word-list.txt
|
data/test/test_dgen.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# PassGen Class tester
|
2
|
-
# Copyright 2015 Richard Davis GPL v3
|
3
|
-
require 'test/unit'
|
4
|
-
require 'dgen/passgen'
|
5
|
-
|
6
|
-
# tests the PassGen class
|
7
|
-
class PassGenTest < Test::Unit::TestCase
|
8
|
-
def test_roll_nums
|
9
|
-
assert_match(/^\d{5}$/, PassGen.new.roll_nums)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_find_word
|
13
|
-
file = File.new('lib/assets/word-list.txt', 'r+')
|
14
|
-
num = '11111'
|
15
|
-
assert_equal(PassGen.new.find_word(file, num), 'a')
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_make_phrase
|
19
|
-
words = %w(this is a test just a test)
|
20
|
-
assert_equal(PassGen.new.make_phrase(words), 'this is a test just a test')
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_generate_phrase
|
24
|
-
n_words = 6
|
25
|
-
p_length = 17
|
26
|
-
file = File.new('lib/assets/word-list.txt', 'r+')
|
27
|
-
assert_match(/\w||\s{17,}/, PassGen.new.generate_phrase(n_words, p_length, file))
|
28
|
-
end
|
29
|
-
end
|