dev-random-passwords 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/randompasswords +72 -0
- data/dev-random-passwords-0.0.1.gem +0 -0
- data/dev-random-passwords-0.0.2.gem +0 -0
- data/dev-random-passwords.gemspec +1 -0
- data/lib/dev-random-passwords.rb +25 -23
- data/lib/dev-random-passwords/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c871a256ac5a707cd16dcaeb3ffa8c07e0240c5
|
4
|
+
data.tar.gz: 76c308d9bc59e2fa2b3f6d2396b50284c5c2edb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7122d2b0b9e31a4b667c4e0282471cce0be4b02d08ad42aba9ecfc5f09423d83a35d0c70faf7e47f452ff278e529cc61bdb221b855ad11833b5904e886539bf4
|
7
|
+
data.tar.gz: c4c8f1ecd9e7590c6fa0c7445f626206ff627cbe71d713d0a2e4538c79cf0377ce2e325cc1de99840585ca59c97e5987b8003de6249f334a1e4f5c184cbb640b
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/dev-random-passwords.svg)](http://badge.fury.io/rb/dev-random-passwords)
|
1
2
|
# Dev-Random-Passwords
|
2
3
|
|
3
4
|
Passwords that need to be used long term and are randomly generated need more randomness than your standard random library. On Linux, Unix or OSX /dev/random can be used to create really secure passwords from random bytes. This gem provides an implementation to do just that.
|
@@ -37,8 +38,7 @@ rpg.set_options({'lowercase' => true, 'uppercase' => true, 'digits' => true, 'l
|
|
37
38
|
|
38
39
|
Generate a new password
|
39
40
|
```ruby
|
40
|
-
rpg.generate
|
41
|
-
=> "J0jhBM9dAPwk"
|
41
|
+
rpg.generate #=> "J0jhBM9dAPwk"
|
42
42
|
```
|
43
43
|
|
44
44
|
Enjoy!
|
data/bin/randompasswords
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'dev-random-passwords'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
rpg = DevRandomPasswords::Generator.new
|
7
|
+
options = {
|
8
|
+
'lowercase' => true,
|
9
|
+
'uppercase' => true,
|
10
|
+
'digits' => true,
|
11
|
+
'special' => true,
|
12
|
+
'include' => nil,
|
13
|
+
'exclude' => nil,
|
14
|
+
'length' => 8,
|
15
|
+
'requirements' => nil
|
16
|
+
}
|
17
|
+
|
18
|
+
|
19
|
+
opts = OptionParser.new do |opts|
|
20
|
+
opts.banner = "Usage: randompasswords [options]"
|
21
|
+
opts.separator ""
|
22
|
+
opts.separator "Specific options:"
|
23
|
+
|
24
|
+
opts.on("-l", "--length [DIGITS]", "Password length in digits") do |length|
|
25
|
+
options['length'] = length.to_i
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-c", "--characters a,b,c",
|
29
|
+
Array, "List of character types to use comma separated") do |list|
|
30
|
+
['lowercase','uppercase','digits','special'].each do |chartype|
|
31
|
+
if list.include? chartype
|
32
|
+
options[chartype] = true
|
33
|
+
else
|
34
|
+
options[chartype] = false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-i", "--include [LETTERS]", "Characters to include in the password") do |include_chars|
|
40
|
+
options['include'] = include_chars
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("-e", "--exclude [LETTERS]", "Characters to exclude from the password") do |exclude_chars|
|
44
|
+
options['exclude'] = exclude_chars
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on("-r", "--require x,y,z",
|
48
|
+
Array, "List of character types to require in the generated password comma separated") do |req|
|
49
|
+
req_hash = {}
|
50
|
+
['lowercase','uppercase','digits','special'].each do |chartype|
|
51
|
+
if req.include? chartype
|
52
|
+
req_hash[chartype] = true
|
53
|
+
else
|
54
|
+
req_hash[chartype] = false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
options['requirements'] = req_hash
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
#Help
|
62
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
63
|
+
puts opts
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
opts.parse!(ARGV)
|
70
|
+
rpg.set_options(options)
|
71
|
+
puts rpg.generate
|
72
|
+
|
Binary file
|
Binary file
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
|
+
spec.executables = ["randompasswords"]
|
20
21
|
|
21
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/dev-random-passwords.rb
CHANGED
@@ -51,14 +51,14 @@ module DevRandomPasswords
|
|
51
51
|
if options['include']
|
52
52
|
if options['include'].respond_to? :each
|
53
53
|
options['include'].each do |char|
|
54
|
-
unless new_set.
|
55
|
-
new_set
|
54
|
+
unless new_set.include? char
|
55
|
+
new_set.insert(-1, char)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
elsif options['include'].respond_to? :split
|
59
59
|
options['include'].split("").each do |char|
|
60
|
-
unless new_set.
|
61
|
-
new_set
|
60
|
+
unless new_set.include? char
|
61
|
+
new_set.insert(-1, char)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -67,14 +67,14 @@ module DevRandomPasswords
|
|
67
67
|
if options['exclude']
|
68
68
|
if options['exclude'].respond_to? :each
|
69
69
|
options['exclude'].each do |char|
|
70
|
-
if new_set.
|
71
|
-
new_set
|
70
|
+
if new_set.include? char
|
71
|
+
new_set = new_set.tr(char, '')
|
72
72
|
end
|
73
73
|
end
|
74
74
|
elsif options['exclude'].respond_to? :split
|
75
75
|
options['exclude'].split("").each do |char|
|
76
|
-
if new_set.
|
77
|
-
new_set
|
76
|
+
if new_set.include? char
|
77
|
+
new_set = new_set.tr(char, '')
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -96,27 +96,29 @@ module DevRandomPasswords
|
|
96
96
|
|
97
97
|
def requirements_met?(password)
|
98
98
|
|
99
|
-
if @requirements
|
100
|
-
if
|
101
|
-
|
99
|
+
if @requirements
|
100
|
+
if @requirements['uppercase']
|
101
|
+
if (password.split("") & UPPERCASE_CHARS.split("")).empty?
|
102
|
+
return false
|
103
|
+
end
|
102
104
|
end
|
103
|
-
end
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
106
|
+
if @requirements['lowercase']
|
107
|
+
if (password.split("") & LOWERCASE_CHARS.split("")).empty?
|
108
|
+
return false
|
109
|
+
end
|
108
110
|
end
|
109
|
-
end
|
110
111
|
|
111
|
-
|
112
|
-
|
113
|
-
|
112
|
+
if @requirements['digits']
|
113
|
+
if (password.split("") & DIGITS.split("")).empty?
|
114
|
+
return false
|
115
|
+
end
|
114
116
|
end
|
115
|
-
end
|
116
117
|
|
117
|
-
|
118
|
-
|
119
|
-
|
118
|
+
if @requirements['special']
|
119
|
+
if (password.split("") & SPECIAL_CHARS.split("")).empty?
|
120
|
+
return false
|
121
|
+
end
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev-random-passwords
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,7 +42,8 @@ description: On Linux, Unix or OSX /dev/random can be used to create really secu
|
|
42
42
|
passwords from random bytes. This gem provides an implementation to do just that.
|
43
43
|
email:
|
44
44
|
- joel@trosic.com
|
45
|
-
executables:
|
45
|
+
executables:
|
46
|
+
- randompasswords
|
46
47
|
extensions: []
|
47
48
|
extra_rdoc_files: []
|
48
49
|
files:
|
@@ -52,6 +53,9 @@ files:
|
|
52
53
|
- LICENSE
|
53
54
|
- README.md
|
54
55
|
- Rakefile
|
56
|
+
- bin/randompasswords
|
57
|
+
- dev-random-passwords-0.0.1.gem
|
58
|
+
- dev-random-passwords-0.0.2.gem
|
55
59
|
- dev-random-passwords.gemspec
|
56
60
|
- lib/.DS_Store
|
57
61
|
- lib/dev-random-passwords.rb
|