xkpassword 0.6.0 → 0.7.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/.rubocop.yml +21 -0
- data/.travis.yml +4 -10
- data/Gemfile +3 -1
- data/README.md +6 -4
- data/Rakefile +4 -2
- data/bin/console +4 -3
- data/lib/xkpassword/config_file.rb +2 -1
- data/lib/xkpassword/generator.rb +140 -136
- data/lib/xkpassword/store.rb +14 -10
- data/lib/xkpassword/version.rb +1 -1
- data/lib/xkpassword/words.rb +59 -53
- data/lib/xkpassword.rb +2 -2
- data/mise.toml +1 -1
- data/xkpassword.gemspec +36 -30
- metadata +34 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fdff2f4fcb5e0c775d3d8581385a5e350daca4b3a1be10901de8839969030b19
|
|
4
|
+
data.tar.gz: 54a97217ed32f945ee871a652238114ececfa9350fd10c66781b371329cc1beb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee8ca201d276a89ba1943a0e73ab647c9bb376d8d94d11c8aa0c6fbf183de85c915556007e4a8873335562906ddc141bab98497d1d506032325e5dec0dd5e80d
|
|
7
|
+
data.tar.gz: d79edd75630888c69445da8c9b01345e0c3398b5afb8ee8538ea1493d19c9c964b0c75ef00265c7ee8256dfb3a48dbbe401ecb3b98af01a35e9bb6adf923294a
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
NewCops: enable
|
|
3
|
+
SuggestExtensions: false
|
|
4
|
+
TargetRubyVersion: 3.3
|
|
5
|
+
|
|
6
|
+
Gemspec/AddRuntimeDependency:
|
|
7
|
+
Enabled: false
|
|
8
|
+
|
|
9
|
+
Gemspec/DevelopmentDependencies:
|
|
10
|
+
Enabled: false
|
|
11
|
+
|
|
12
|
+
Metrics/AbcSize:
|
|
13
|
+
Max: 21
|
|
14
|
+
|
|
15
|
+
Metrics/BlockLength:
|
|
16
|
+
Exclude:
|
|
17
|
+
- 'spec/**/*'
|
|
18
|
+
- 'xkpassword.gemspec'
|
|
19
|
+
|
|
20
|
+
Style/Documentation:
|
|
21
|
+
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
+
cache: bundler
|
|
2
3
|
rvm:
|
|
3
|
-
-
|
|
4
|
-
-
|
|
5
|
-
-
|
|
6
|
-
- 2.6.6
|
|
7
|
-
- 2.7.2
|
|
8
|
-
- 3.0.0
|
|
9
|
-
before_install: gem install bundler
|
|
4
|
+
- '3.3'
|
|
5
|
+
- '3.4'
|
|
6
|
+
- '4.0'
|
|
10
7
|
script: bundle exec rspec
|
|
11
|
-
addons:
|
|
12
|
-
code_climate:
|
|
13
|
-
repo_token: 1a754006a15f983b39ddc25c65543fab4a956a4ff607a636e135415c5350e4e0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[](https://badge.fury.io/rb/xkpassword)
|
|
2
|
-
[](https://app.travis-ci.com/jdeen/xkpassword)
|
|
3
3
|
[](http://inch-ci.org/github/jdeen/xkpassword)
|
|
4
4
|
[](https://codeclimate.com/github/jdeen/xkpassword)
|
|
5
5
|
|
|
@@ -29,8 +29,8 @@ it.
|
|
|
29
29
|
|
|
30
30
|
## Installation
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
The gem currently supports the Ruby release series that Ruby core still maintains:
|
|
33
|
+
Ruby 3.3, Ruby 3.4, and Ruby 4.0.
|
|
34
34
|
|
|
35
35
|
Add this line to your application's Gemfile:
|
|
36
36
|
|
|
@@ -148,6 +148,8 @@ The default `:xkcd` preset keeps the gem's original behavior of generating 4 wor
|
|
|
148
148
|
`case_transform` supports `:upcase`, `:downcase`, and `:capitalize`, and applies the
|
|
149
149
|
selected transform to every generated word in the password.
|
|
150
150
|
|
|
151
|
+
Word lengths, words, and random uppercasing are all chosen with Ruby's `SecureRandom`.
|
|
152
|
+
|
|
151
153
|
## The GEM
|
|
152
154
|
|
|
153
155
|
Releases are intended for functional updates such as new features and bug fixes.
|
|
@@ -155,7 +157,7 @@ Check the Git tags or RubyGems release history for the latest published version.
|
|
|
155
157
|
|
|
156
158
|
## Development
|
|
157
159
|
|
|
158
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run
|
|
160
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run
|
|
159
161
|
`bin/console` for an interactive prompt that will allow you to experiment.
|
|
160
162
|
|
|
161
163
|
To install this gem onto your local machine, run `bundle exec rake install`. To release
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'xkpassword'
|
|
5
6
|
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -10,5 +11,5 @@ require "xkpassword"
|
|
|
10
11
|
# require "pry"
|
|
11
12
|
# Pry.start
|
|
12
13
|
|
|
13
|
-
require
|
|
14
|
+
require 'irb'
|
|
14
15
|
IRB.start
|
data/lib/xkpassword/generator.rb
CHANGED
|
@@ -1,159 +1,163 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
1
4
|
require 'xkpassword/words'
|
|
2
5
|
|
|
3
6
|
# The Generator class which finds words based on the requirement and using the provided options to build a
|
|
4
7
|
# new random passowrd.
|
|
5
8
|
# Presets provide convenient defaults for common password styles, and callers can override any
|
|
6
9
|
# preset-derived value by passing explicit generation options.
|
|
7
|
-
#
|
|
10
|
+
#
|
|
8
11
|
# @attr_reader [XKPassword::Words] words A word database that gen provide you words for the length required
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
12
|
+
module XKPassword
|
|
13
|
+
class Generator
|
|
14
|
+
# The preset used when `:preset` is omitted.
|
|
15
|
+
DEFAULT_PRESET = :xkcd
|
|
16
|
+
|
|
17
|
+
# Built-in password presets.
|
|
18
|
+
#
|
|
19
|
+
# - `:xkcd` generates 4 words between 4 and 8 letters separated by `-`, preserving the gem's
|
|
20
|
+
# original default behavior.
|
|
21
|
+
# - `:web32` generates 4 shorter words between 4 and 5 letters separated by `-`.
|
|
22
|
+
# - `:wifi` generates 6 words between 4 and 8 letters separated by `-`.
|
|
23
|
+
# - `:security` generates 6 lowercase words between 4 and 8 letters separated by spaces.
|
|
24
|
+
# - `:apple_id` generates 3 words between 4 and 7 letters separated by `-`.
|
|
25
|
+
PRESETS = {
|
|
26
|
+
xkcd: {
|
|
27
|
+
case_transform: nil,
|
|
28
|
+
max_length: 8,
|
|
29
|
+
min_length: 4,
|
|
30
|
+
separator: '-',
|
|
31
|
+
words: 4
|
|
32
|
+
},
|
|
33
|
+
web32: {
|
|
34
|
+
case_transform: nil,
|
|
35
|
+
max_length: 5,
|
|
36
|
+
min_length: 4,
|
|
37
|
+
separator: '-',
|
|
38
|
+
words: 4
|
|
39
|
+
},
|
|
40
|
+
wifi: {
|
|
41
|
+
case_transform: nil,
|
|
42
|
+
max_length: 8,
|
|
43
|
+
min_length: 4,
|
|
44
|
+
separator: '-',
|
|
45
|
+
words: 6
|
|
46
|
+
},
|
|
47
|
+
security: {
|
|
48
|
+
case_transform: :downcase,
|
|
49
|
+
max_length: 8,
|
|
50
|
+
min_length: 4,
|
|
51
|
+
separator: ' ',
|
|
52
|
+
words: 6
|
|
53
|
+
},
|
|
54
|
+
apple_id: {
|
|
55
|
+
case_transform: nil,
|
|
56
|
+
max_length: 7,
|
|
57
|
+
min_length: 4,
|
|
58
|
+
separator: '-',
|
|
59
|
+
words: 3
|
|
60
|
+
}
|
|
61
|
+
}.freeze
|
|
62
|
+
VALID_CASE_TRANSFORMS = %i[upcase downcase capitalize].freeze
|
|
63
|
+
|
|
64
|
+
attr_reader :words
|
|
65
|
+
|
|
66
|
+
def initialize
|
|
67
|
+
@words = XKPassword::Words.new
|
|
68
|
+
end
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
70
|
+
# Generates a password absed on the configuration provided.
|
|
71
|
+
# A preset supplies a base configuration and any explicit options passed in `options` override
|
|
72
|
+
# those preset defaults.
|
|
73
|
+
#
|
|
74
|
+
# @param [Hash] options The options to populate a generator
|
|
75
|
+
# @option options [String, Symbol] :preset The preset to use. Supports `:xkcd`, `:web32`,
|
|
76
|
+
# `:wifi`, `:security`, and `:apple_id`.
|
|
77
|
+
# String values like `"apple_id"` and `"apple-id"`
|
|
78
|
+
# are normalized to `:apple_id`. Defaults to `:xkcd`.
|
|
79
|
+
# @option options [Integer] :words The number of words to include in the generated password
|
|
80
|
+
# @option options [String] :separator The separator symbol to use joining words used in password
|
|
81
|
+
# @option options [Integer] :min_length The minimum length of a word to be used in the process
|
|
82
|
+
# @option options [Integer] :max_length The maximum length of a word to be used in the process
|
|
83
|
+
# @option options [String, Symbol] :case_transform The transform to apply to every generated word
|
|
84
|
+
#
|
|
85
|
+
# @return [String] The generated password
|
|
86
|
+
#
|
|
87
|
+
# @example Using the default xkcd preset
|
|
88
|
+
# generator = XKPassword::Generator.new
|
|
89
|
+
# generator.generate
|
|
90
|
+
#
|
|
91
|
+
# @example Using the security preset
|
|
92
|
+
# generator = XKPassword::Generator.new
|
|
93
|
+
# generator.generate(preset: :security)
|
|
94
|
+
#
|
|
95
|
+
# @example Populating the method with a preset and explicit overrides
|
|
96
|
+
# options = {
|
|
97
|
+
# preset: :security,
|
|
98
|
+
# separator: ' ',
|
|
99
|
+
# words: 6,
|
|
100
|
+
# min_length: 4,
|
|
101
|
+
# max_length: 8,
|
|
102
|
+
# case_transform: :downcase
|
|
103
|
+
# }
|
|
104
|
+
#
|
|
105
|
+
# generator = XKPassword::Generator.new
|
|
106
|
+
# generator.generate(options)
|
|
107
|
+
#
|
|
108
|
+
# @example Built-in preset defaults
|
|
109
|
+
# :xkcd # 4 words, 4..8 letters, "-" separator, random per-word uppercasing
|
|
110
|
+
# :web32 # 4 words, 4..5 letters, "-" separator, random per-word uppercasing
|
|
111
|
+
# :wifi # 6 words, 4..8 letters, "-" separator, random per-word uppercasing
|
|
112
|
+
# :security # 6 words, 4..8 letters, " " separator, lowercase
|
|
113
|
+
# :apple_id # 3 words, 4..7 letters, "-" separator, random per-word uppercasing
|
|
114
|
+
def generate(options = nil)
|
|
115
|
+
options = (options || {}).dup
|
|
116
|
+
preset = normalize_preset(options.delete(:preset))
|
|
117
|
+
options = PRESETS.fetch(preset).merge(options)
|
|
118
|
+
case_transform = normalize_case_transform(options[:case_transform])
|
|
119
|
+
length_vals = (options[:min_length]..options[:max_length]).to_a
|
|
120
|
+
|
|
121
|
+
data = options[:words].times.map do
|
|
122
|
+
word = words.random(length_vals.sample(random: SecureRandom))
|
|
123
|
+
transform_word(word, case_transform)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
data.join(options[:separator])
|
|
120
127
|
end
|
|
121
|
-
|
|
122
|
-
data.join(options[:separator])
|
|
123
|
-
end
|
|
124
128
|
|
|
125
|
-
|
|
129
|
+
private
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
def transform_word(word, case_transform)
|
|
132
|
+
return randomly_upcase(word) unless case_transform
|
|
129
133
|
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
word.public_send(case_transform)
|
|
135
|
+
end
|
|
132
136
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
137
|
+
def randomly_upcase(word)
|
|
138
|
+
upcase = [true, false].sample(random: SecureRandom)
|
|
139
|
+
word = word.upcase if upcase
|
|
140
|
+
word
|
|
141
|
+
end
|
|
138
142
|
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
def normalize_case_transform(case_transform)
|
|
144
|
+
return nil if case_transform.nil?
|
|
141
145
|
|
|
142
|
-
|
|
146
|
+
case_transform = case_transform.to_sym if case_transform.is_a?(String)
|
|
143
147
|
|
|
144
|
-
|
|
148
|
+
return case_transform if VALID_CASE_TRANSFORMS.include?(case_transform)
|
|
145
149
|
|
|
146
|
-
|
|
147
|
-
|
|
150
|
+
raise ArgumentError, "case_transform should be one of: #{VALID_CASE_TRANSFORMS.join(', ')}"
|
|
151
|
+
end
|
|
148
152
|
|
|
149
|
-
|
|
150
|
-
|
|
153
|
+
def normalize_preset(preset)
|
|
154
|
+
return DEFAULT_PRESET if preset.nil?
|
|
151
155
|
|
|
152
|
-
|
|
156
|
+
preset = preset.strip.downcase.tr(' -', '_').to_sym if preset.is_a?(String)
|
|
153
157
|
|
|
154
|
-
|
|
158
|
+
return preset if PRESETS.key?(preset)
|
|
155
159
|
|
|
156
|
-
|
|
160
|
+
raise ArgumentError, "preset should be one of: #{PRESETS.keys.join(', ')}"
|
|
161
|
+
end
|
|
157
162
|
end
|
|
158
|
-
|
|
159
163
|
end
|
data/lib/xkpassword/store.rb
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
SOURCE = 'google-10000-english-no-swears.txt'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
module XKPassword
|
|
4
|
+
class Store
|
|
5
|
+
SOURCE = 'google-10000-english-no-swears.txt'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
attr_reader :data
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
load_data
|
|
11
|
+
end
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
private
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
def load_data
|
|
16
|
+
path = "#{File.dirname(__FILE__)}/data/#{SOURCE}"
|
|
17
|
+
@data = File.readlines(path).map { |item| item.delete("\n") }
|
|
18
|
+
end
|
|
15
19
|
end
|
|
16
20
|
end
|
data/lib/xkpassword/version.rb
CHANGED
data/lib/xkpassword/words.rb
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
1
4
|
require 'xkpassword/store'
|
|
2
5
|
|
|
3
6
|
# XKPassword::Words basically is a mini database of words. Its job is to provide words
|
|
@@ -10,70 +13,73 @@ require 'xkpassword/store'
|
|
|
10
13
|
# @attr_reader [Hash] words A collection of words store in a hash with the
|
|
11
14
|
# corresponding key to a word be a function of the
|
|
12
15
|
# lenght of the word.
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
module XKPassword
|
|
17
|
+
class Words
|
|
18
|
+
attr_reader :words
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
def initialize
|
|
21
|
+
@words = {}
|
|
22
|
+
setup
|
|
23
|
+
end
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
words[key(length)]
|
|
29
|
-
end
|
|
25
|
+
# Provide an array of words having the specified number of characters in it
|
|
26
|
+
#
|
|
27
|
+
# @param length [String] The number of characters of words should contain
|
|
28
|
+
#
|
|
29
|
+
# @return [Array<String>] Words from the source that match the length requirement.
|
|
30
|
+
def with_length(length)
|
|
31
|
+
raise ArgumentError 'Length should be a numeric' unless length.is_a? Numeric
|
|
30
32
|
|
|
33
|
+
words[key(length)]
|
|
34
|
+
end
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
with_length(length).sample
|
|
40
|
-
end
|
|
36
|
+
# Provides a random word with the specified length, chosen with SecureRandom
|
|
37
|
+
#
|
|
38
|
+
# @param length [Integer] The number of characters the word should contain
|
|
39
|
+
#
|
|
40
|
+
# @return [String] A random word with length
|
|
41
|
+
def random(length)
|
|
42
|
+
raise ArgumentError, 'Length should be numeric' unless length.is_a? Numeric
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# @return [Array<Integer>] A collection of lengths of words available
|
|
45
|
-
def lengths
|
|
46
|
-
words.keys.map{ |key| key.delete("l").to_i }
|
|
47
|
-
end
|
|
44
|
+
with_length(length).sample(random: SecureRandom)
|
|
45
|
+
end
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
# Provide lengths available in the databse
|
|
48
|
+
#
|
|
49
|
+
# @return [Array<Integer>] A collection of lengths of words available
|
|
50
|
+
def lengths
|
|
51
|
+
words.keys.map { |key| key.delete('l').to_i }
|
|
52
|
+
end
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
# The lenght of the shortest word
|
|
55
|
+
#
|
|
56
|
+
# @return [Integer] The length of the shortest word
|
|
57
|
+
def min_length
|
|
58
|
+
lengths.min
|
|
59
|
+
end
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
# The length of the longest word
|
|
62
|
+
#
|
|
63
|
+
# @return [Integer] The length of the longest word
|
|
64
|
+
def max_length
|
|
65
|
+
lengths.max
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
def setup
|
|
71
|
+
store = XKPassword::Store.new
|
|
72
|
+
data = store.data
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
data.each do |datum|
|
|
75
|
+
k = key(datum.length)
|
|
76
|
+
words[k] = [] unless words[k]
|
|
77
|
+
words[k] << datum
|
|
78
|
+
end
|
|
73
79
|
end
|
|
74
|
-
end
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
def key(length)
|
|
82
|
+
"l#{length}"
|
|
83
|
+
end
|
|
78
84
|
end
|
|
79
85
|
end
|
data/lib/xkpassword.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
module XKPassword
|
|
3
4
|
# Generates a random password by intializing a `XKPassword::Generator` instance.
|
|
4
5
|
# This accepts argumennts identcal to the above class.
|
|
5
6
|
#
|
|
@@ -34,7 +35,6 @@ module XKPassword
|
|
|
34
35
|
generator = XKPassword::Generator.new
|
|
35
36
|
generator.generate(options)
|
|
36
37
|
end
|
|
37
|
-
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
require 'xkpassword/version'
|
data/mise.toml
CHANGED
data/xkpassword.gemspec
CHANGED
|
@@ -1,36 +1,42 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
|
|
4
6
|
require 'xkpassword/version'
|
|
5
7
|
|
|
6
8
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name =
|
|
9
|
+
spec.name = 'xkpassword'
|
|
8
10
|
spec.version = XKPassword::VERSION
|
|
9
|
-
spec.authors = [
|
|
10
|
-
spec.email = [
|
|
11
|
-
|
|
12
|
-
spec.summary =
|
|
13
|
-
spec.description =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
spec.homepage =
|
|
25
|
-
spec.license =
|
|
26
|
-
|
|
27
|
-
spec.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
spec.
|
|
34
|
-
spec.
|
|
35
|
-
|
|
11
|
+
spec.authors = ['Ziyan Junaideen']
|
|
12
|
+
spec.email = ['ziyan@jdeen.com']
|
|
13
|
+
|
|
14
|
+
spec.summary = 'Hard to crack - XKPassword Generator for Ruby'
|
|
15
|
+
spec.description = <<~DESCRIPTION
|
|
16
|
+
Passwords are hard to remember, especially when they are hard to crack. I'd spend countless hours
|
|
17
|
+
every year resetting passwords and eventually running out of options that I can remember. I found
|
|
18
|
+
an interesting concept in an XKCD comic: generate passwords using words so they are easier to
|
|
19
|
+
remember. Here is XKPassword, a library you can install into your Ruby app or run independently
|
|
20
|
+
from the command line.
|
|
21
|
+
|
|
22
|
+
Wish you a safer future.
|
|
23
|
+
|
|
24
|
+
Ziyan
|
|
25
|
+
DESCRIPTION
|
|
26
|
+
spec.homepage = 'https://github.com/jdeen/xkpassword'
|
|
27
|
+
spec.license = 'MIT'
|
|
28
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.3', '< 4.1')
|
|
29
|
+
spec.metadata = {
|
|
30
|
+
'rubygems_mfa_required' => 'true'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |file| file.match(%r{^(test|spec|features)/}) }
|
|
34
|
+
spec.bindir = 'exe'
|
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |file| File.basename(file) }
|
|
36
|
+
spec.require_paths = ['lib']
|
|
37
|
+
|
|
38
|
+
spec.add_dependency 'artii', '~> 2.1'
|
|
39
|
+
spec.add_development_dependency 'bundler', '>= 2.5', '< 3.0'
|
|
40
|
+
spec.add_development_dependency 'rake', '~> 13.3'
|
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.13'
|
|
36
42
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xkpassword
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ziyan Junaideen
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: artii
|
|
@@ -28,50 +27,60 @@ dependencies:
|
|
|
28
27
|
name: bundler
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.5'
|
|
33
|
+
- - "<"
|
|
32
34
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
35
|
+
version: '3.0'
|
|
34
36
|
type: :development
|
|
35
37
|
prerelease: false
|
|
36
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
39
|
requirements:
|
|
38
|
-
- - "
|
|
40
|
+
- - ">="
|
|
39
41
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '2.
|
|
42
|
+
version: '2.5'
|
|
43
|
+
- - "<"
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '3.0'
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
|
42
47
|
name: rake
|
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
|
44
49
|
requirements:
|
|
45
50
|
- - "~>"
|
|
46
51
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '13.
|
|
52
|
+
version: '13.3'
|
|
48
53
|
type: :development
|
|
49
54
|
prerelease: false
|
|
50
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
56
|
requirements:
|
|
52
57
|
- - "~>"
|
|
53
58
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '13.
|
|
59
|
+
version: '13.3'
|
|
55
60
|
- !ruby/object:Gem::Dependency
|
|
56
61
|
name: rspec
|
|
57
62
|
requirement: !ruby/object:Gem::Requirement
|
|
58
63
|
requirements:
|
|
59
64
|
- - "~>"
|
|
60
65
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '3.
|
|
66
|
+
version: '3.13'
|
|
62
67
|
type: :development
|
|
63
68
|
prerelease: false
|
|
64
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
70
|
requirements:
|
|
66
71
|
- - "~>"
|
|
67
72
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '3.
|
|
69
|
-
description:
|
|
70
|
-
crack. I'd spend countless hours
|
|
71
|
-
running out of options that I can remember. I found
|
|
72
|
-
|
|
73
|
-
Here is XKPassword, a
|
|
74
|
-
|
|
73
|
+
version: '3.13'
|
|
74
|
+
description: |
|
|
75
|
+
Passwords are hard to remember, especially when they are hard to crack. I'd spend countless hours
|
|
76
|
+
every year resetting passwords and eventually running out of options that I can remember. I found
|
|
77
|
+
an interesting concept in an XKCD comic: generate passwords using words so they are easier to
|
|
78
|
+
remember. Here is XKPassword, a library you can install into your Ruby app or run independently
|
|
79
|
+
from the command line.
|
|
80
|
+
|
|
81
|
+
Wish you a safer future.
|
|
82
|
+
|
|
83
|
+
Ziyan
|
|
75
84
|
email:
|
|
76
85
|
- ziyan@jdeen.com
|
|
77
86
|
executables:
|
|
@@ -81,6 +90,7 @@ extra_rdoc_files: []
|
|
|
81
90
|
files:
|
|
82
91
|
- ".gitignore"
|
|
83
92
|
- ".rspec"
|
|
93
|
+
- ".rubocop.yml"
|
|
84
94
|
- ".travis.yml"
|
|
85
95
|
- CODE_OF_CONDUCT.md
|
|
86
96
|
- Gemfile
|
|
@@ -106,8 +116,8 @@ files:
|
|
|
106
116
|
homepage: https://github.com/jdeen/xkpassword
|
|
107
117
|
licenses:
|
|
108
118
|
- MIT
|
|
109
|
-
metadata:
|
|
110
|
-
|
|
119
|
+
metadata:
|
|
120
|
+
rubygems_mfa_required: 'true'
|
|
111
121
|
rdoc_options: []
|
|
112
122
|
require_paths:
|
|
113
123
|
- lib
|
|
@@ -115,15 +125,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
115
125
|
requirements:
|
|
116
126
|
- - ">="
|
|
117
127
|
- !ruby/object:Gem::Version
|
|
118
|
-
version: '
|
|
128
|
+
version: '3.3'
|
|
129
|
+
- - "<"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '4.1'
|
|
119
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
133
|
requirements:
|
|
121
134
|
- - ">="
|
|
122
135
|
- !ruby/object:Gem::Version
|
|
123
136
|
version: '0'
|
|
124
137
|
requirements: []
|
|
125
|
-
rubygems_version:
|
|
126
|
-
signing_key:
|
|
138
|
+
rubygems_version: 4.0.6
|
|
127
139
|
specification_version: 4
|
|
128
140
|
summary: Hard to crack - XKPassword Generator for Ruby
|
|
129
141
|
test_files: []
|