easy_passwords 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +4 -11
- data/Gemfile +1 -1
- data/README.md +2 -0
- data/easy_passwords.gemspec +3 -6
- data/lib/easy_passwords/easy_passwords.rb +45 -43
- data/lib/easy_passwords/version.rb +1 -1
- metadata +18 -38
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 33b44c7ae93ae47a020b52010f2da4ad14adfeb4
|
4
|
+
data.tar.gz: 4229c09699050e8d80b1448f6009246e6c71c504
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4b7b1a9bf60f2be97cf1ca5ce62e43d3701f24b87cd6a033f630b21d593cd6cfb4334a3aef28ee8f676b7d8110617b87912eae7673dba5b804ea0e0975abd90
|
7
|
+
data.tar.gz: d08bef840c1f262a022221d442142cca09e4fe45fb29a0c0940995c325d106b32379f36eb89967bf963b905c49ec535b75d022dca16b9c895260685e2eadee2a
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
gemspec
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# easy_passwords.rb
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/piotrze/easy_passwords.svg?branch=master)](https://travis-ci.org/piotrze/easy_passwords)
|
4
|
+
|
3
5
|
easy_passwords.rb is a Ruby implementation of passwdqc's easy_passwords, a random pronouncable password generator.
|
4
6
|
|
5
7
|
## Installation
|
data/easy_passwords.gemspec
CHANGED
@@ -10,16 +10,13 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.authors = ["Pete"]
|
11
11
|
s.email = 'piotr.bliszczyk@gmail.com'
|
12
12
|
s.homepage = 'https://github.com/piotrze/easy_passwords'
|
13
|
+
s.license = 'MIT'
|
13
14
|
|
14
15
|
s.files = `git ls-files`.split("\n")
|
15
16
|
s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
16
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
18
|
s.require_paths = ['lib']
|
18
19
|
|
19
|
-
s.
|
20
|
-
s.
|
21
|
-
|
22
|
-
s.add_development_dependency 'rake'
|
23
|
-
s.add_development_dependency 'rspec'
|
24
|
-
s.add_development_dependency 'debugger'
|
20
|
+
s.add_development_dependency 'rake', '~> 0'
|
21
|
+
s.add_development_dependency 'rspec', '~> 0'
|
25
22
|
end
|
@@ -7,7 +7,7 @@ require 'securerandom'
|
|
7
7
|
# Examples
|
8
8
|
#
|
9
9
|
# EasyPasswords.generate
|
10
|
-
# # => "
|
10
|
+
# # => "merger4Hick"
|
11
11
|
#
|
12
12
|
# EasyPasswords.new.generate
|
13
13
|
# # => "employ-Royal"
|
@@ -19,11 +19,10 @@ require 'securerandom'
|
|
19
19
|
# # => "min5"
|
20
20
|
#
|
21
21
|
module EasyPasswords
|
22
|
-
|
23
22
|
DEFAULT_MAX_LENGTH = 12
|
24
23
|
MIN_WORD_LENGTH = 3
|
25
24
|
MAX_WORD_LENGTH = 6
|
26
|
-
SEPARATORS =
|
25
|
+
SEPARATORS = '-123456789'.freeze
|
27
26
|
|
28
27
|
# Public: Returns a random generated password string.
|
29
28
|
#
|
@@ -42,44 +41,42 @@ module EasyPasswords
|
|
42
41
|
# # => "spate7Coup"
|
43
42
|
#
|
44
43
|
# Returns a password string.
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def self.generate(max_length = DEFAULT_MAX_LENGTH, separators = SEPARATORS)
|
45
|
+
self::Generator.new(separators).generate max_length
|
46
|
+
end
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
def self.new
|
49
|
+
self::Generator.new
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
52
|
+
class Generator
|
53
|
+
def initialize(separators = EasyPasswords::SEPARATORS)
|
54
|
+
@@wordlist_size = @@wordlist.length
|
55
|
+
@@separators = separators
|
56
|
+
@@separators_size = @@separators.length
|
57
|
+
@rand = SecureRandom
|
58
|
+
end
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
60
|
+
# Public: Returns a random generated password string.
|
61
|
+
#
|
62
|
+
# max_length - max number of characters used in password, it could generate password shorter by 3 characters.
|
63
|
+
#
|
64
|
+
# Example
|
65
|
+
#
|
66
|
+
# generate 8
|
67
|
+
# # => "Fun_Crop"
|
68
|
+
#
|
69
|
+
# generate
|
70
|
+
# # => "spate7Coup"
|
71
|
+
#
|
72
|
+
# Returns a password string.
|
73
|
+
def generate(max_length = EasyPasswords::DEFAULT_MAX_LENGTH)
|
74
|
+
fail "Password minimal length is #{EasyPasswords::MIN_WORD_LENGTH}" if max_length < EasyPasswords::MIN_WORD_LENGTH
|
75
|
+
output = ''
|
77
76
|
while output.size < (max_length - (EasyPasswords::MIN_WORD_LENGTH - 1))
|
78
|
-
output
|
79
|
-
|
80
|
-
|
81
|
-
end
|
82
|
-
output
|
77
|
+
add_part(output, max_length)
|
78
|
+
end
|
79
|
+
output
|
83
80
|
end
|
84
81
|
|
85
82
|
private
|
@@ -98,12 +95,17 @@ module EasyPasswords
|
|
98
95
|
|
99
96
|
def random_word(maxsize = EasyPasswords::MAX_WORD_LENGTH)
|
100
97
|
list = if maxsize < EasyPasswords::MAX_WORD_LENGTH
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
98
|
+
@@wordlist.select { |w| w.size <= maxsize }
|
99
|
+
else
|
100
|
+
@@wordlist
|
101
|
+
end
|
105
102
|
word = list[@rand.random_number(list.size)]
|
106
|
-
|
103
|
+
@rand.random_number(2) == 0 ? word.capitalize : word
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_part(output, max_length)
|
107
|
+
output << random_word(choose_word_length(max_length, output.size))
|
108
|
+
output << @@separators[@rand.random_number(@@separators_size)] if output.size < max_length
|
107
109
|
end
|
108
|
-
|
110
|
+
end
|
109
111
|
end
|
metadata
CHANGED
@@ -1,62 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_passwords
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
5
|
-
prerelease:
|
4
|
+
version: '0.4'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Pete
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: debugger
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
38
|
+
- - "~>"
|
60
39
|
- !ruby/object:Gem::Version
|
61
40
|
version: '0'
|
62
41
|
description: Easy password is a Ruby implementation of passwdqc's easy_passwords,
|
@@ -66,8 +45,9 @@ executables: []
|
|
66
45
|
extensions: []
|
67
46
|
extra_rdoc_files: []
|
68
47
|
files:
|
69
|
-
- .gitignore
|
70
|
-
- .
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rubocop.yml"
|
50
|
+
- ".travis.yml"
|
71
51
|
- Gemfile
|
72
52
|
- README.md
|
73
53
|
- Rakefile
|
@@ -79,28 +59,28 @@ files:
|
|
79
59
|
- spec/lib/easy_passwords_spec.rb
|
80
60
|
- spec/spec_helper.rb
|
81
61
|
homepage: https://github.com/piotrze/easy_passwords
|
82
|
-
licenses:
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
83
65
|
post_install_message:
|
84
66
|
rdoc_options: []
|
85
67
|
require_paths:
|
86
68
|
- lib
|
87
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
70
|
requirements:
|
90
|
-
- -
|
71
|
+
- - ">="
|
91
72
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
73
|
+
version: '0'
|
93
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
75
|
requirements:
|
96
|
-
- -
|
76
|
+
- - ">="
|
97
77
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
78
|
+
version: '0'
|
99
79
|
requirements: []
|
100
80
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
81
|
+
rubygems_version: 2.2.3
|
102
82
|
signing_key:
|
103
|
-
specification_version:
|
83
|
+
specification_version: 4
|
104
84
|
summary: Easy passwords generator in Ruby
|
105
85
|
test_files:
|
106
86
|
- spec/lib/easy_passwords_spec.rb
|