xkpassword 0.5.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/.gitignore +0 -1
- data/.rubocop.yml +21 -0
- data/.travis.yml +4 -10
- data/Gemfile +3 -1
- data/README.md +64 -25
- data/Rakefile +4 -2
- data/bin/console +4 -3
- data/doc/README.md +9 -0
- data/doc/presets.md +37 -0
- data/exe/xkpassword +3 -45
- data/lib/xkpassword/cli.rb +125 -0
- data/lib/xkpassword/config_file.rb +106 -0
- data/lib/xkpassword/generator.rb +140 -136
- data/lib/xkpassword/store.rb +14 -10
- data/lib/xkpassword/version.rb +3 -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 +38 -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/.gitignore
CHANGED
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
|
|
|
@@ -50,43 +50,90 @@ Or install it yourself as:
|
|
|
50
50
|
~# gem install xkpassword
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
Installing the gem also installs the `xkpassword` executable.
|
|
54
|
+
|
|
53
55
|
## Usage
|
|
54
56
|
|
|
55
|
-
You can use this app
|
|
56
|
-
|
|
57
|
+
You can use this app as a Ruby gem in your application or as a command line utility.
|
|
58
|
+
For a fuller guide to presets and examples, see [doc/README.md](doc/README.md).
|
|
59
|
+
|
|
60
|
+
### Command Line
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
the
|
|
61
|
-
full list of options.
|
|
62
|
+
The command line app accepts the same generation options as `XKPassword.generate`.
|
|
63
|
+
If you installed the gem, use the executable directly. If you are working from a
|
|
64
|
+
checkout, run the executable through Bundler.
|
|
62
65
|
|
|
63
66
|
```bash
|
|
64
67
|
~# xkpassword
|
|
65
68
|
~# xkpassword --help
|
|
69
|
+
~# bundle exec exe/xkpassword
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Global CLI config
|
|
73
|
+
|
|
74
|
+
The CLI reads optional defaults from `~/.xkpassword`. The file uses YAML, so it can
|
|
75
|
+
include comments while you experiment with different settings. Use `xkpassword --init`
|
|
76
|
+
to create a commented starter file.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
~# xkpassword --init
|
|
80
|
+
~# xkpassword
|
|
81
|
+
~# xkpassword --separator .
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
# ~/.xkpassword
|
|
86
|
+
# preset: wifi
|
|
87
|
+
words: 5
|
|
88
|
+
min_length: 4
|
|
89
|
+
max_length: 8
|
|
90
|
+
separator: "-"
|
|
91
|
+
# case_transform: capitalize
|
|
66
92
|
```
|
|
67
93
|
|
|
94
|
+
CLI flags always override values from `~/.xkpassword`, so you can keep preferred defaults
|
|
95
|
+
in the file and still override them per command.
|
|
96
|
+
|
|
68
97
|
### Ruby Apps
|
|
69
98
|
|
|
99
|
+
Use the library API inside your Ruby application:
|
|
100
|
+
|
|
70
101
|
```ruby
|
|
71
102
|
require 'xkpassword'
|
|
72
103
|
|
|
73
104
|
options = {
|
|
74
|
-
|
|
105
|
+
words: 5,
|
|
106
|
+
min_length: 5,
|
|
107
|
+
max_length: 8,
|
|
108
|
+
separator: '.',
|
|
109
|
+
case_transform: :capitalize,
|
|
75
110
|
}
|
|
76
111
|
|
|
77
112
|
XKPassword.generate(options)
|
|
78
113
|
```
|
|
79
114
|
|
|
80
|
-
|
|
81
|
-
|
|
115
|
+
You can still use presets when they fit your use case:
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
require 'xkpassword'
|
|
119
|
+
|
|
120
|
+
XKPassword.generate(preset: :security, separator: '.')
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
If you are generating multiple passwords at once, use a single generator instance so
|
|
124
|
+
the dictionary only needs to be loaded once:
|
|
82
125
|
|
|
83
126
|
```ruby
|
|
84
127
|
require 'xkpassword/generator'
|
|
85
128
|
|
|
86
129
|
options = {
|
|
87
|
-
|
|
130
|
+
words: 4,
|
|
131
|
+
min_length: 4,
|
|
132
|
+
max_length: 6,
|
|
133
|
+
separator: '-',
|
|
134
|
+
case_transform: :downcase,
|
|
88
135
|
}
|
|
89
|
-
|
|
136
|
+
|
|
90
137
|
generator = XKPassword::Generator.new
|
|
91
138
|
generator.generate(options)
|
|
92
139
|
|
|
@@ -101,6 +148,8 @@ The default `:xkcd` preset keeps the gem's original behavior of generating 4 wor
|
|
|
101
148
|
`case_transform` supports `:upcase`, `:downcase`, and `:capitalize`, and applies the
|
|
102
149
|
selected transform to every generated word in the password.
|
|
103
150
|
|
|
151
|
+
Word lengths, words, and random uppercasing are all chosen with Ruby's `SecureRandom`.
|
|
152
|
+
|
|
104
153
|
## The GEM
|
|
105
154
|
|
|
106
155
|
Releases are intended for functional updates such as new features and bug fixes.
|
|
@@ -108,7 +157,7 @@ Check the Git tags or RubyGems release history for the latest published version.
|
|
|
108
157
|
|
|
109
158
|
## Development
|
|
110
159
|
|
|
111
|
-
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
|
|
112
161
|
`bin/console` for an interactive prompt that will allow you to experiment.
|
|
113
162
|
|
|
114
163
|
To install this gem onto your local machine, run `bundle exec rake install`. To release
|
|
@@ -116,16 +165,6 @@ a new version, update the version number in `version.rb`, and then run `bundle e
|
|
|
116
165
|
release`, which will create a git tag for the version, push git commits and tags, and push
|
|
117
166
|
the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
118
167
|
|
|
119
|
-
## TODO
|
|
120
|
-
|
|
121
|
-
Some of the things I am interested in doing in the near future.
|
|
122
|
-
|
|
123
|
-
- More tests, didn't have the time to write it all
|
|
124
|
-
- Local configuration file -> ex: `~/.xkpassword`
|
|
125
|
-
- Check for a better dictionary
|
|
126
|
-
- Ability to provide a dictionary (this should help languages other than English)
|
|
127
|
-
- A black-list - words that will not show up in the generation
|
|
128
|
-
|
|
129
168
|
## Contributing
|
|
130
169
|
|
|
131
170
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/xkpassword.
|
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/doc/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# XKPassword Docs
|
|
2
|
+
|
|
3
|
+
Additional documentation for this gem lives in this folder.
|
|
4
|
+
|
|
5
|
+
- [Preset guide](presets.md)
|
|
6
|
+
- [Project README](../README.md) for installation, Ruby gem usage, CLI usage, and `~/.xkpassword` defaults
|
|
7
|
+
- [GitHub repository](https://github.com/jdeen/xkpassword)
|
|
8
|
+
|
|
9
|
+
Use these docs for feature-specific details, then jump back to the main README or repository as needed.
|
data/doc/presets.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Presets
|
|
2
|
+
|
|
3
|
+
Back to the [docs index](README.md) or the [project README](../README.md).
|
|
4
|
+
|
|
5
|
+
`XKPassword.generate` and `XKPassword::Generator#generate` accept a `:preset` option.
|
|
6
|
+
If omitted, `:preset` defaults to `:xkcd`.
|
|
7
|
+
|
|
8
|
+
## Supported presets
|
|
9
|
+
|
|
10
|
+
| Preset | Defaults |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `:xkcd` | 4 words, 4-8 letters, `-` separator, random per-word uppercasing |
|
|
13
|
+
| `:web32` | 4 words, 4-5 letters, `-` separator, random per-word uppercasing |
|
|
14
|
+
| `:wifi` | 6 words, 4-8 letters, `-` separator, random per-word uppercasing |
|
|
15
|
+
| `:security` | 6 words, 4-8 letters, space separator, lowercase words |
|
|
16
|
+
| `:apple_id` | 3 words, 4-7 letters, `-` separator, random per-word uppercasing |
|
|
17
|
+
|
|
18
|
+
## Examples
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
require 'xkpassword'
|
|
22
|
+
|
|
23
|
+
XKPassword.generate
|
|
24
|
+
XKPassword.generate(preset: :wifi)
|
|
25
|
+
XKPassword.generate(preset: :security, separator: '.')
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
You can pass a preset as a symbol or string. String values like `"apple_id"` and `"apple-id"`
|
|
29
|
+
are normalized to the matching preset.
|
|
30
|
+
|
|
31
|
+
Explicit options always win over the preset defaults, so this is valid:
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
XKPassword.generate(preset: :xkcd, words: 6, case_transform: :capitalize)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For the full source and latest updates, see the [GitHub repository](https://github.com/jdeen/xkpassword).
|
data/exe/xkpassword
CHANGED
|
@@ -1,48 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
require '
|
|
4
|
-
require 'artii'
|
|
4
|
+
require 'xkpassword/cli'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
require 'xkpassword'
|
|
8
|
-
|
|
9
|
-
artii = Artii::Base.new font: 'standard'
|
|
10
|
-
message = """
|
|
11
|
-
#{ artii.asciify('XKPassword') }
|
|
12
|
-
by Ziyan Junaideen
|
|
13
|
-
|
|
14
|
-
How many times have you changed your password just because you forgot it?
|
|
15
|
-
Well, you are not alone. In todays security requirements, passwords need
|
|
16
|
-
to be secure and difficult to break. Passwords need to be secure, sure,
|
|
17
|
-
but they can also be easy to remember. Follow up this XKCD article for more
|
|
18
|
-
information - http://xkcd.com/936/
|
|
19
|
-
|
|
20
|
-
This does exactly what the picture predicts. You can use this in your Ruby
|
|
21
|
-
applications (Ex: Rails, Sinatra) or standalone if you install the gem (as
|
|
22
|
-
you have done here).
|
|
23
|
-
|
|
24
|
-
Wish you all the best keeping things secure.
|
|
25
|
-
|
|
26
|
-
Ziyan Junaideen
|
|
27
|
-
ziyan@jdeen.com
|
|
28
|
-
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
options = {}
|
|
32
|
-
OptionParser.new do |opts|
|
|
33
|
-
opts.banner = "Usage: ./exe/xkpassword [options]"
|
|
34
|
-
|
|
35
|
-
opts.on('-v', '--version', 'Gem version') { options[:version] = true }
|
|
36
|
-
opts.on('-i', '--info', 'Gem info') { options[:info] = true }
|
|
37
|
-
|
|
38
|
-
opts.on('--words [INTEGER]', 'Number of wrods to be used in the generated password') { |words| options[:words] = words.to_i }
|
|
39
|
-
opts.on('--min-length [INTEGER]', 'Minimum length of a word') { |min| options[:min_length] = min.to_i }
|
|
40
|
-
opts.on('--max-length [INTEGER]', 'Maximum length of a word') { |max| options[:max_length] = max.to_i }
|
|
41
|
-
opts.on('--separator [STRING]', 'The separator to separate password') { |separator| options[:separator] = separator }
|
|
42
|
-
opts.on('--case-transform [STRING]', 'Transform each word using upcase, downcase, or capitalize') { |case_transform| options[:case_transform] = case_transform }
|
|
43
|
-
opts.on('--preset [STRING]', 'Preset to use: xkcd, web32, wifi, security, or apple_id') { |preset| options[:preset] = preset }
|
|
44
|
-
end.parse!
|
|
45
|
-
|
|
46
|
-
puts message if options[:info]
|
|
47
|
-
puts XKPassword::VERSION if options[:version]
|
|
48
|
-
puts XKPassword.generate(options) if !options[:info] && !options[:version]
|
|
6
|
+
exit XKPassword::CLI.new.run
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'optparse'
|
|
4
|
+
require 'artii'
|
|
5
|
+
|
|
6
|
+
require 'xkpassword'
|
|
7
|
+
require 'xkpassword/config_file'
|
|
8
|
+
|
|
9
|
+
module XKPassword
|
|
10
|
+
# Command-line entrypoint for the xkpassword executable.
|
|
11
|
+
class CLI
|
|
12
|
+
INFO_MESSAGE = <<~TEXT.freeze
|
|
13
|
+
#{Artii::Base.new(font: 'standard').asciify('XKPassword')}
|
|
14
|
+
by Ziyan Junaideen
|
|
15
|
+
|
|
16
|
+
How many times have you changed your password just because you forgot it?
|
|
17
|
+
Well, you are not alone. In todays security requirements, passwords need
|
|
18
|
+
to be secure and difficult to break. Passwords need to be secure, sure,
|
|
19
|
+
but they can also be easy to remember. Follow up this XKCD article for more
|
|
20
|
+
information - http://xkcd.com/936/
|
|
21
|
+
|
|
22
|
+
This does exactly what the picture predicts. You can use this in your Ruby
|
|
23
|
+
applications (Ex: Rails, Sinatra) or standalone if you install the gem (as
|
|
24
|
+
you have done here).
|
|
25
|
+
|
|
26
|
+
Wish you all the best keeping things secure.
|
|
27
|
+
|
|
28
|
+
Ziyan Junaideen
|
|
29
|
+
ziyan@jdeen.com
|
|
30
|
+
TEXT
|
|
31
|
+
|
|
32
|
+
def initialize(argv = ARGV, stdout: $stdout, stderr: $stderr, env: ENV)
|
|
33
|
+
@argv = argv.dup
|
|
34
|
+
@stdout = stdout
|
|
35
|
+
@stderr = stderr
|
|
36
|
+
@config_file = XKPassword::ConfigFile.new(XKPassword::ConfigFile.default_path(env))
|
|
37
|
+
@options = {}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def run
|
|
41
|
+
option_parser.parse!(@argv)
|
|
42
|
+
|
|
43
|
+
return initialize_config if @options[:init]
|
|
44
|
+
return write_special_output if special_output?
|
|
45
|
+
|
|
46
|
+
options = @config_file.load.merge(@options)
|
|
47
|
+
write_line(XKPassword.generate(options))
|
|
48
|
+
rescue OptionParser::ParseError, XKPassword::ConfigFile::Error, ArgumentError => e
|
|
49
|
+
@stderr.puts(e.message)
|
|
50
|
+
1
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def option_parser
|
|
56
|
+
@option_parser ||= OptionParser.new do |opts|
|
|
57
|
+
opts.banner = 'Usage: xkpassword [options]'
|
|
58
|
+
|
|
59
|
+
add_command_options(opts)
|
|
60
|
+
add_generation_options(opts)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def add_command_options(opts)
|
|
65
|
+
opts.on('-v', '--version', 'Gem version') { @options[:version] = true }
|
|
66
|
+
opts.on('-i', '--info', 'Gem info') { @options[:info] = true }
|
|
67
|
+
opts.on('--init', "Create #{@config_file.path} with commented defaults") { @options[:init] = true }
|
|
68
|
+
opts.on('-h', '--help', 'Show help') { @options[:help] = true }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def add_generation_options(opts)
|
|
72
|
+
add_numeric_generation_options(opts)
|
|
73
|
+
add_text_generation_options(opts)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def add_numeric_generation_options(opts)
|
|
77
|
+
opts.on(
|
|
78
|
+
'--words [INTEGER]',
|
|
79
|
+
'Number of words to use in the generated password'
|
|
80
|
+
) { |words| @options[:words] = words.to_i }
|
|
81
|
+
opts.on('--min-length [INTEGER]', 'Minimum length of a word') { |min| @options[:min_length] = min.to_i }
|
|
82
|
+
opts.on('--max-length [INTEGER]', 'Maximum length of a word') { |max| @options[:max_length] = max.to_i }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def add_text_generation_options(opts)
|
|
86
|
+
opts.on(
|
|
87
|
+
'--separator [STRING]',
|
|
88
|
+
'The separator between generated words'
|
|
89
|
+
) { |separator| @options[:separator] = separator }
|
|
90
|
+
opts.on(
|
|
91
|
+
'--case-transform [STRING]',
|
|
92
|
+
'Transform each word using upcase, downcase, or capitalize'
|
|
93
|
+
) { |case_transform| @options[:case_transform] = case_transform }
|
|
94
|
+
add_preset_option(opts)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def add_preset_option(opts)
|
|
98
|
+
opts.on(
|
|
99
|
+
'--preset [STRING]',
|
|
100
|
+
'Preset to use: xkcd, web32, wifi, security, or apple_id'
|
|
101
|
+
) { |preset| @options[:preset] = preset }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def special_output?
|
|
105
|
+
@options[:help] || @options[:info] || @options[:version]
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def write_special_output
|
|
109
|
+
write_line(option_parser) if @options[:help]
|
|
110
|
+
write_line(INFO_MESSAGE) if @options[:info]
|
|
111
|
+
write_line(XKPassword::VERSION) if @options[:version]
|
|
112
|
+
0
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def initialize_config
|
|
116
|
+
path = @config_file.init!
|
|
117
|
+
write_line("Created #{path}")
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def write_line(message)
|
|
121
|
+
@stdout.puts(message)
|
|
122
|
+
0
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'psych'
|
|
4
|
+
|
|
5
|
+
module XKPassword
|
|
6
|
+
# Loads and initializes the CLI config file stored at ~/.xkpassword.
|
|
7
|
+
class ConfigFile
|
|
8
|
+
class Error < StandardError
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
ALLOWED_OPTIONS = %i[
|
|
12
|
+
preset
|
|
13
|
+
words
|
|
14
|
+
min_length
|
|
15
|
+
max_length
|
|
16
|
+
separator
|
|
17
|
+
case_transform
|
|
18
|
+
].freeze
|
|
19
|
+
INTEGER_OPTIONS = %i[words min_length max_length].freeze
|
|
20
|
+
TEMPLATE = <<~YAML
|
|
21
|
+
# Global defaults for the xkpassword CLI.
|
|
22
|
+
# Remove the leading "#" from any setting you want to enable.
|
|
23
|
+
#
|
|
24
|
+
# Supported keys:
|
|
25
|
+
# preset: xkcd, web32, wifi, security, apple_id
|
|
26
|
+
# words: integer
|
|
27
|
+
# min_length: integer
|
|
28
|
+
# max_length: integer
|
|
29
|
+
# separator: string
|
|
30
|
+
# case_transform: upcase, downcase, capitalize
|
|
31
|
+
#
|
|
32
|
+
# Example:
|
|
33
|
+
# preset: wifi
|
|
34
|
+
# words: 6
|
|
35
|
+
# min_length: 4
|
|
36
|
+
# max_length: 8
|
|
37
|
+
# separator: "-"
|
|
38
|
+
# case_transform: capitalize
|
|
39
|
+
YAML
|
|
40
|
+
|
|
41
|
+
attr_reader :path
|
|
42
|
+
|
|
43
|
+
def initialize(path = self.class.default_path)
|
|
44
|
+
@path = path
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.default_path(env = ENV)
|
|
48
|
+
home = env['HOME'] || Dir.home
|
|
49
|
+
File.expand_path('.xkpassword', home)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def load
|
|
53
|
+
return {} unless File.exist?(path)
|
|
54
|
+
|
|
55
|
+
data = Psych.safe_load(File.read(path), aliases: false)
|
|
56
|
+
return {} if data.nil?
|
|
57
|
+
raise Error, "#{path} must contain a YAML mapping of options" unless data.is_a?(Hash)
|
|
58
|
+
|
|
59
|
+
normalize_options(data)
|
|
60
|
+
rescue Psych::SyntaxError => e
|
|
61
|
+
raise Error, "Could not parse #{path}: #{e.message}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def init!
|
|
65
|
+
raise Error, "#{path} already exists" if File.exist?(path)
|
|
66
|
+
|
|
67
|
+
File.write(path, TEMPLATE)
|
|
68
|
+
path
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
def normalize_options(data)
|
|
74
|
+
data.each_with_object({}) do |(key, value), normalized|
|
|
75
|
+
normalized_key = normalize_key(key)
|
|
76
|
+
|
|
77
|
+
unless ALLOWED_OPTIONS.include?(normalized_key)
|
|
78
|
+
raise Error, "Unsupported config option #{key.inspect} in #{path}"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
normalized[normalized_key] = normalize_value(normalized_key, value)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def normalize_key(key)
|
|
86
|
+
key.to_s.strip.downcase.tr(' -', '_').to_sym
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def normalize_value(key, value)
|
|
90
|
+
return normalize_integer(key, value) if INTEGER_OPTIONS.include?(key)
|
|
91
|
+
|
|
92
|
+
return value if value.nil? || value.is_a?(String) || value.is_a?(Symbol)
|
|
93
|
+
|
|
94
|
+
raise Error, "#{key} in #{path} should be a string or left unset"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def normalize_integer(key, value)
|
|
98
|
+
integer_value = value.is_a?(String) ? Integer(value, 10) : value
|
|
99
|
+
return integer_value if integer_value.is_a?(Integer)
|
|
100
|
+
|
|
101
|
+
raise Error, "#{key} in #{path} should be an integer"
|
|
102
|
+
rescue ArgumentError, TypeError
|
|
103
|
+
raise Error, "#{key} in #{path} should be an integer"
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
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
|
|
@@ -90,8 +100,12 @@ files:
|
|
|
90
100
|
- bin/console
|
|
91
101
|
- bin/setup
|
|
92
102
|
- bin/xkpassword
|
|
103
|
+
- doc/README.md
|
|
104
|
+
- doc/presets.md
|
|
93
105
|
- exe/xkpassword
|
|
94
106
|
- lib/xkpassword.rb
|
|
107
|
+
- lib/xkpassword/cli.rb
|
|
108
|
+
- lib/xkpassword/config_file.rb
|
|
95
109
|
- lib/xkpassword/data/google-10000-english-no-swears.txt
|
|
96
110
|
- lib/xkpassword/generator.rb
|
|
97
111
|
- lib/xkpassword/store.rb
|
|
@@ -102,8 +116,8 @@ files:
|
|
|
102
116
|
homepage: https://github.com/jdeen/xkpassword
|
|
103
117
|
licenses:
|
|
104
118
|
- MIT
|
|
105
|
-
metadata:
|
|
106
|
-
|
|
119
|
+
metadata:
|
|
120
|
+
rubygems_mfa_required: 'true'
|
|
107
121
|
rdoc_options: []
|
|
108
122
|
require_paths:
|
|
109
123
|
- lib
|
|
@@ -111,15 +125,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
111
125
|
requirements:
|
|
112
126
|
- - ">="
|
|
113
127
|
- !ruby/object:Gem::Version
|
|
114
|
-
version: '
|
|
128
|
+
version: '3.3'
|
|
129
|
+
- - "<"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '4.1'
|
|
115
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
133
|
requirements:
|
|
117
134
|
- - ">="
|
|
118
135
|
- !ruby/object:Gem::Version
|
|
119
136
|
version: '0'
|
|
120
137
|
requirements: []
|
|
121
|
-
rubygems_version:
|
|
122
|
-
signing_key:
|
|
138
|
+
rubygems_version: 4.0.6
|
|
123
139
|
specification_version: 4
|
|
124
140
|
summary: Hard to crack - XKPassword Generator for Ruby
|
|
125
141
|
test_files: []
|