funny_yubikey_generator 0.2.0 → 0.4.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 +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +24 -18
- data/Rakefile +5 -0
- data/exe/generate_funny_yubikey +1 -1
- data/funny_yubikey_generator.gemspec +3 -5
- data/lib/funny_yubikey_generator.rb +17 -30
- data/lib/indexed_words.yaml +7577 -0
- data/preview.png +0 -0
- metadata +6 -6
- 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: aa628988e7878d56e67bdb26d912dc7d21f419f9f0e75fb6ccc845a8937c1a56
|
4
|
+
data.tar.gz: 7dbeea9dc0759e3f894fa2893530cf79a041dbc29de99087b9ccbd7ddceb27bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f91e58a6fc9d03de37625515a93918f33e7e3fc41334f4e1dd0ac982ae2a740cbcd67bff7cb2e422fd4eb21c29c9c3217e5af19084967abda92775f6d12a040e
|
7
|
+
data.tar.gz: 1d225d62b4b474bbdaad7edff6ee078194b7ea6a72146f9bc07844666048336c0d0eef4a9d07b9ead94799da7f822babd13ce44a2cd7ab274bd8d57a4f0a7a21
|
data/Gemfile
CHANGED
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,33 +18,37 @@ 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)
|
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
|
42
48
|
|
43
49
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
44
50
|
|
45
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version
|
51
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the `spec.version` in [funny_yubikey_generator.gemspec](funny_yubikey_generator.gemspec), and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
46
52
|
|
47
53
|
## Contributing
|
48
54
|
|
@@ -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]
|
data/exe/generate_funny_yubikey
CHANGED
@@ -27,7 +27,7 @@ end.parse!
|
|
27
27
|
|
28
28
|
generator = if dictionary
|
29
29
|
raise "Could not find file #{dictionary}" unless File.exist?(dictionary)
|
30
|
-
FunnyYubikeyGenerator.
|
30
|
+
FunnyYubikeyGenerator.from_dictionary(File.open(dictionary))
|
31
31
|
else
|
32
32
|
FunnyYubikeyGenerator.instance
|
33
33
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "lib/funny_yubikey_generator"
|
4
|
-
|
5
3
|
Gem::Specification.new do |spec|
|
6
4
|
spec.name = "funny_yubikey_generator"
|
7
|
-
spec.version =
|
5
|
+
spec.version = "0.4.0"
|
8
6
|
spec.authors = ["Xavier Delamotte"]
|
9
7
|
spec.email = ["git@xade.eu"]
|
10
8
|
|
11
|
-
spec.summary = "
|
12
|
-
spec.description = "
|
9
|
+
spec.summary = "Generate funny looking yubikey OTP containing words based on a dictionary."
|
10
|
+
spec.description = "Generate funny looking yubikey OTP containing words based on a dictionary."
|
13
11
|
spec.homepage = "https://github.com/x4d3/funny_yubikey_generator"
|
14
12
|
spec.license = "MIT"
|
15
13
|
spec.required_ruby_version = ">= 2.6.0"
|
@@ -3,24 +3,24 @@
|
|
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
|
9
10
|
COLORS = %i[red green yellow blue magenta cyan]
|
11
|
+
LETTERS = "cbdefghijklnrtuv"
|
12
|
+
WORD_REGEX = /^[#{Regexp.quote(LETTERS)}]+{4,}$/
|
10
13
|
private_constant :COLORS
|
14
|
+
private_constant :LETTERS
|
15
|
+
|
11
16
|
class << self
|
12
|
-
def
|
13
|
-
|
14
|
-
|
17
|
+
def from_dictionary(dictionary)
|
18
|
+
indexed_words = filter_and_index_words(dictionary)
|
19
|
+
new(indexed_words: indexed_words)
|
15
20
|
end
|
16
21
|
|
17
|
-
def
|
18
|
-
|
19
|
-
@singleton__mutex__.synchronize {
|
20
|
-
return @singleton__instance__ if @singleton__instance__
|
21
|
-
@singleton__instance__ = new
|
22
|
-
}
|
23
|
-
@singleton__instance__
|
22
|
+
def filter_and_index_words(dictionary)
|
23
|
+
dictionary.scan(WORD_REGEX).group_by(&:length)
|
24
24
|
end
|
25
25
|
|
26
26
|
def generate(colorize: false)
|
@@ -28,20 +28,13 @@ class FunnyYubikeyGenerator
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
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)
|
31
|
+
def initialize(indexed_words: load_default_indexed_words)
|
32
|
+
@indexed_words = indexed_words
|
39
33
|
end
|
40
34
|
|
41
35
|
def generate(colorize: false)
|
42
|
-
|
43
|
-
|
44
|
-
@dictionary[s].sample
|
36
|
+
words = random_partition(40, @indexed_words.keys).map do |s|
|
37
|
+
@indexed_words[s].sample
|
45
38
|
end
|
46
39
|
if colorize
|
47
40
|
words.map!.with_index { |w, i| w.colorize(COLORS[i % COLORS.length]) }
|
@@ -51,14 +44,8 @@ class FunnyYubikeyGenerator
|
|
51
44
|
|
52
45
|
private
|
53
46
|
|
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
|
47
|
+
def load_default_indexed_words
|
48
|
+
YAML.load_file(File.join(__dir__, "indexed_words.yaml"))
|
62
49
|
end
|
63
50
|
|
64
51
|
def random_partition(target, word_lengths)
|