funny_yubikey_generator 0.2.0 → 0.3.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/Gemfile.lock +1 -1
- data/README.md +23 -17
- data/Rakefile +5 -0
- data/lib/funny_yubikey_generator.rb +20 -30
- data/lib/indexed_words.yaml +7577 -0
- data/preview.png +0 -0
- metadata +4 -4
- data/lib/words.txt +0 -10000
- data/sig/yubikey_generator.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee03f537080c0eee30e79ca418b86395103442b5b7212cb862de5065fa5af037
|
4
|
+
data.tar.gz: b7351abcdaef208798a496a93d9b6529010ea965f1a4f7a3ba507e72ee9421e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cea34ab297af170a44379b8123d55def53f2bb4db9de3bd12567fecf1b6ed51c47f99eda0792d7eb6c01738ee48aa1a7d1c38b9fcb31f8e9f9d82e21099838e8
|
7
|
+
data.tar.gz: f781e1fef15707693c9fb1874e125c9d322916fce9f5658be85d0e91fe62aacc774a56011306da3ff91f212be10be7ca570a1dc024de6b7ec5c80d7979326e6e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# FunnyYubikeyGenerator
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/funny_yubikey_generator)
|
4
|
+
|
3
5
|
Generate funny looking [yubikey OTP](https://developers.yubico.com/OTP/OTPs_Explained.html) containing words based on a dictionary.
|
4
6
|
|
5
7
|
## Installation
|
@@ -16,26 +18,30 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
16
18
|
|
17
19
|
As CLI:
|
18
20
|
```bash
|
19
|
-
|
20
|
-
|
21
|
+
gem install funny_yubikey_generator
|
22
|
+
generate_funny_yubikey -c
|
21
23
|
```
|
22
24
|
|
25
|
+

|
26
|
+
|
23
27
|
In Ruby:
|
24
28
|
```ruby
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
29
|
+
require "funny_yubikey_generator"
|
30
|
+
puts FunnyYubikeyGenerator.generate(colorize: true)
|
31
|
+
|
32
|
+
dictionary = <<~DICO
|
33
|
+
crude
|
34
|
+
blubber
|
35
|
+
futile
|
36
|
+
lutrin
|
37
|
+
interbelligerent
|
38
|
+
reinterference
|
39
|
+
DICO
|
40
|
+
generator = FunnyYubikeyGenerator.from_dictionary(dictionary.split("\n"))
|
41
|
+
puts generator.generate(colorize: true)
|
42
|
+
|
43
|
+
generator = FunnyYubikeyGenerator.from_dictionary(File.open("/usr/share/dict/words"))
|
44
|
+
puts generator.generate(colorize: false)
|
39
45
|
```
|
40
46
|
|
41
47
|
## Development
|
@@ -54,4 +60,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
54
60
|
|
55
61
|
## Code of Conduct
|
56
62
|
|
57
|
-
Everyone interacting in the
|
63
|
+
Everyone interacting in the FunnyYubikeyGenerator project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/x4d3/funny_yubikey_generator/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rake/testtask"
|
5
|
+
require "yaml"
|
5
6
|
|
6
7
|
Rake::TestTask.new(:test) do |t|
|
7
8
|
t.libs << "test"
|
@@ -9,6 +10,10 @@ Rake::TestTask.new(:test) do |t|
|
|
9
10
|
t.test_files = FileList["test/**/*_test.rb"]
|
10
11
|
end
|
11
12
|
|
13
|
+
task :generate_index_words do
|
14
|
+
puts FunnyYubikeyGenerator.filter_and_index_words(File.open("/usr/share/dict/words")).to_yaml
|
15
|
+
end
|
16
|
+
|
12
17
|
require "standard/rake"
|
13
18
|
|
14
19
|
task default: %i[test standard]
|
@@ -3,24 +3,27 @@
|
|
3
3
|
require "singleton"
|
4
4
|
require "colorize"
|
5
5
|
require "set"
|
6
|
+
require "yaml"
|
6
7
|
|
7
8
|
class FunnyYubikeyGenerator
|
8
|
-
|
9
|
+
include Singleton
|
10
|
+
VERSION = "0.3.0"
|
9
11
|
COLORS = %i[red green yellow blue magenta cyan]
|
12
|
+
LETTERS = "cbdefghijklnrtuv".chars.to_set
|
13
|
+
|
10
14
|
private_constant :COLORS
|
15
|
+
private_constant :LETTERS
|
16
|
+
|
11
17
|
class << self
|
12
|
-
def
|
13
|
-
|
14
|
-
|
18
|
+
def from_dictionary(dictionary)
|
19
|
+
indexed_words = filter_and_index_words(dictionary)
|
20
|
+
new(indexed_words: indexed_words)
|
15
21
|
end
|
16
22
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@singleton__instance__ = new
|
22
|
-
}
|
23
|
-
@singleton__instance__
|
23
|
+
def filter_and_index_words(dictionary)
|
24
|
+
dictionary.map(&:strip).select { |line|
|
25
|
+
line.size > 3 && line.chars.all? { |c| LETTERS.include?(c) }
|
26
|
+
}.group_by(&:length)
|
24
27
|
end
|
25
28
|
|
26
29
|
def generate(colorize: false)
|
@@ -28,20 +31,13 @@ class FunnyYubikeyGenerator
|
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
def initialize(dictionary: default_dictionary, letters: "cbdefghijklnrtuv".chars.to_set)
|
34
|
-
@dictionary = dictionary.map(&:strip).select { |line|
|
35
|
-
line.chars.all? do |c|
|
36
|
-
letters.include?(c)
|
37
|
-
end
|
38
|
-
}.group_by(&:length)
|
34
|
+
def initialize(indexed_words: load_default_indexed_words)
|
35
|
+
@indexed_words = indexed_words
|
39
36
|
end
|
40
37
|
|
41
38
|
def generate(colorize: false)
|
42
|
-
|
43
|
-
|
44
|
-
@dictionary[s].sample
|
39
|
+
words = random_partition(40, @indexed_words.keys).map do |s|
|
40
|
+
@indexed_words[s].sample
|
45
41
|
end
|
46
42
|
if colorize
|
47
43
|
words.map!.with_index { |w, i| w.colorize(COLORS[i % COLORS.length]) }
|
@@ -51,14 +47,8 @@ class FunnyYubikeyGenerator
|
|
51
47
|
|
52
48
|
private
|
53
49
|
|
54
|
-
def
|
55
|
-
|
56
|
-
"/usr/share/dict/words",
|
57
|
-
"/usr/dict/word",
|
58
|
-
File.join(__dir__, "words.txt")
|
59
|
-
].each do |path|
|
60
|
-
return File.open(path) if File.exist?(path)
|
61
|
-
end
|
50
|
+
def load_default_indexed_words
|
51
|
+
YAML.load_file(File.join(__dir__, "indexed_words.yaml"))
|
62
52
|
end
|
63
53
|
|
64
54
|
def random_partition(target, word_lengths)
|