funny_yubikey_generator 0.4.0 → 0.6.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 +4 -1
- data/Rakefile +5 -4
- data/exe/generate_funny_yubikey +15 -6
- data/funny_yubikey_generator.gemspec +1 -1
- data/lib/funny_yubikey_generator.rb +10 -10
- data/lib/words.txt +659 -0
- metadata +3 -3
- data/lib/indexed_words.yaml +0 -7577
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 824fac803e68edd1fab0a5b47b57bb9bb62ea203e2074f56498a82462a143159
|
4
|
+
data.tar.gz: 2bfddd9f014d436eeafda4415a0375d12e5dbac2aed9fdf644d5e060b99b5764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa5b822175a82071efdb71ad2cc1946f4320037ad9b0e37473f00f0d53d0d858dd294588054240c84ea1898897681ebd2bd33a5c94ed11b643de0a83334a3b1c
|
7
|
+
data.tar.gz: 388ae7f297fb1184c8b0d5b36dae2c23bfd3a26dc0e37ba7a242086ab207e718b6264b234701978ff2f50976911687a49b2436474e66d82466c73ba9e3a5d3c9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# FunnyYubikeyGenerator
|
2
2
|
|
3
|
+
[](https://github.com/x4d3/funny_yubikey_generator/actions/workflows/main.yml)
|
3
4
|
[](https://badge.fury.io/rb/funny_yubikey_generator)
|
4
5
|
|
6
|
+
|
7
|
+
|
5
8
|
Generate funny looking [yubikey OTP](https://developers.yubico.com/OTP/OTPs_Explained.html) containing words based on a dictionary.
|
6
9
|
|
7
10
|
## Installation
|
@@ -40,7 +43,7 @@ DICO
|
|
40
43
|
generator = FunnyYubikeyGenerator.from_dictionary(dictionary)
|
41
44
|
puts generator.generate(colorize: true)
|
42
45
|
|
43
|
-
generator = FunnyYubikeyGenerator.from_dictionary(File.
|
46
|
+
generator = FunnyYubikeyGenerator.from_dictionary(File.read("/usr/share/dict/words"))
|
44
47
|
puts generator.generate(colorize: false)
|
45
48
|
```
|
46
49
|
|
data/Rakefile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "funny_yubikey_generator"
|
3
4
|
require "bundler/gem_tasks"
|
4
5
|
require "rake/testtask"
|
5
6
|
require "yaml"
|
7
|
+
require "standard/rake"
|
6
8
|
|
7
9
|
Rake::TestTask.new(:test) do |t|
|
8
10
|
t.libs << "test"
|
@@ -10,10 +12,9 @@ Rake::TestTask.new(:test) do |t|
|
|
10
12
|
t.test_files = FileList["test/**/*_test.rb"]
|
11
13
|
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
# rake "filter_words[lib/words.txt]" > lib/words2.txt
|
16
|
+
task :filter_words, [:path] do |_, args|
|
17
|
+
puts FunnyYubikeyGenerator.filter_words(File.read(args[:path])).join("\n")
|
15
18
|
end
|
16
19
|
|
17
|
-
require "standard/rake"
|
18
|
-
|
19
20
|
task default: %i[test standard]
|
data/exe/generate_funny_yubikey
CHANGED
@@ -4,10 +4,11 @@ require "optparse"
|
|
4
4
|
|
5
5
|
colorize = false
|
6
6
|
dictionary = nil
|
7
|
+
number = 1
|
7
8
|
|
8
9
|
OptionParser.new do |opts|
|
9
10
|
opts.banner = "Usage: generate_funny_yubikey [options]"
|
10
|
-
opts.separator "Generate a yubikey TOP containing words"
|
11
|
+
opts.separator "Generate a yubikey TOP containing english words"
|
11
12
|
opts.separator "Example: generate_funny_yubikey -c"
|
12
13
|
|
13
14
|
opts.separator ""
|
@@ -20,16 +21,24 @@ OptionParser.new do |opts|
|
|
20
21
|
opts.on("-c", "--color", "Output with colors") do
|
21
22
|
colorize = true
|
22
23
|
end
|
23
|
-
opts.on("-
|
24
|
+
opts.on("-n [NUMBER]", "--number", Integer, "Generate NUMBER Yubikey TOP") do |n|
|
25
|
+
number = n if n
|
26
|
+
end
|
27
|
+
opts.on("-d [DICTIONARY]", "--dictionary", "Path to the file containing the list of words to pick from") do |dico|
|
24
28
|
dictionary = dico
|
25
29
|
end
|
26
30
|
end.parse!
|
27
31
|
|
28
32
|
generator = if dictionary
|
29
|
-
|
30
|
-
|
33
|
+
path = File.expand_path(dictionary)
|
34
|
+
unless File.exist?(path)
|
35
|
+
warn("Could not find file: #{dictionary}")
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
FunnyYubikeyGenerator.from_dictionary(File.read(path))
|
31
39
|
else
|
32
40
|
FunnyYubikeyGenerator.instance
|
33
41
|
end
|
34
|
-
|
35
|
-
puts generator.generate(colorize: colorize)
|
42
|
+
number.times do
|
43
|
+
puts generator.generate(colorize: colorize)
|
44
|
+
end
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require "singleton"
|
4
4
|
require "colorize"
|
5
|
-
require "set"
|
6
|
-
require "yaml"
|
7
5
|
|
8
6
|
class FunnyYubikeyGenerator
|
9
7
|
include Singleton
|
@@ -12,15 +10,16 @@ class FunnyYubikeyGenerator
|
|
12
10
|
WORD_REGEX = /^[#{Regexp.quote(LETTERS)}]+{4,}$/
|
13
11
|
private_constant :COLORS
|
14
12
|
private_constant :LETTERS
|
13
|
+
private_constant :WORD_REGEX
|
15
14
|
|
16
15
|
class << self
|
17
16
|
def from_dictionary(dictionary)
|
18
|
-
|
19
|
-
new(
|
17
|
+
words = filter_words(dictionary)
|
18
|
+
new(words: words)
|
20
19
|
end
|
21
20
|
|
22
|
-
def
|
23
|
-
dictionary.scan(WORD_REGEX)
|
21
|
+
def filter_words(dictionary)
|
22
|
+
dictionary.scan(WORD_REGEX)
|
24
23
|
end
|
25
24
|
|
26
25
|
def generate(colorize: false)
|
@@ -28,8 +27,8 @@ class FunnyYubikeyGenerator
|
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
|
-
def initialize(
|
32
|
-
@indexed_words =
|
30
|
+
def initialize(words: load_default_words)
|
31
|
+
@indexed_words = words.group_by(&:length)
|
33
32
|
end
|
34
33
|
|
35
34
|
def generate(colorize: false)
|
@@ -44,8 +43,9 @@ class FunnyYubikeyGenerator
|
|
44
43
|
|
45
44
|
private
|
46
45
|
|
47
|
-
def
|
48
|
-
|
46
|
+
def load_default_words
|
47
|
+
default_file_path = File.join(__dir__, "words.txt")
|
48
|
+
File.readlines(default_file_path, chomp: true)
|
49
49
|
end
|
50
50
|
|
51
51
|
def random_partition(target, word_lengths)
|