passlock 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3a3ba1dc65c64b1e78baa629e9eb5caaf944006
4
- data.tar.gz: f49c1fb9eb58c57435e5bfdf673620ed5d7a1e94
3
+ metadata.gz: 26eb8e67214b0f31c36a251687d4f9d4bed5a0b2
4
+ data.tar.gz: 8128e88426c9f8e7c38a66deba3d5b398cd00a79
5
5
  SHA512:
6
- metadata.gz: 92b6950104907b2174839346bffa9bd25960c7b1e02a564fcf33d81efdd8c856b83533f47165d9004396b49e3b96c72b21c80620af1135c0530d1ecbde83c476
7
- data.tar.gz: 8ab254d11e47f2009ddff9b0025f044d55b5341243bbc95fadf8a63078f62b689c03ec5b3e76bba9f44d29e90ca300f9ee28cf5257c467ef1865eb360f2ca832
6
+ metadata.gz: 9d72a5389a118d9e7191e1f7e8d814c5ca526059775fda22b6b373e81e85eaca41cd63435699d4ba7bbd61d5d79ee3b399b93fae308ed0401769100c3185922b
7
+ data.tar.gz: 7474d629676e56bb4eb2f16f9a56d772c06346341c4cef44b8c7988325a68ceba3b5cd8ba3e0700627e3b9b0b548e57e0b78d09e87488ce0f3acd977f46d5462
@@ -6,113 +6,114 @@ require 'digest/sha2'
6
6
  require 'hmac-sha1'
7
7
  require 'securerandom'
8
8
 
9
+ # PassLock base module
9
10
  module PassLock
10
- @opts = {
11
- 'number' => '1234567890',
12
- 'upletter' => 'qwertyuiopasdfghjklzxcvbnm'.upcase,
13
- 'downletter' => 'qwertyuiopasdfghjklzxcvbnm',
14
- 'symbols' => %q{`~!@#$%^&*()_+-=[]{}\|;':",.<>/?}
15
- }
11
+ @opts = {
12
+ 'number' => '1234567890',
13
+ 'upletter' => 'qwertyuiopasdfghjklzxcvbnm'.upcase,
14
+ 'downletter' => 'qwertyuiopasdfghjklzxcvbnm',
15
+ 'symbols' => %q{`~!@#$%^&*()_+-=[]{}\|;':",.<>/?}
16
+ }
16
17
 
17
- # A randomly generated passord.
18
- # @param options [Array] Options for the password given in strings. Available strings `number` `upletter` `downletter` `symbol`
19
- # @param length [Integer] How long the password will be
20
- # @return [String] Returns the Base64-encoded version of the password.
21
- def self.cpass(options, length)
22
- options = options != Array || options.empty? ? options : ['number', 'upletter', 'downletter', 'symbol']
23
- length = length.is_a(Integer) && length > 0 ? length : 10
24
- chars = []
25
- result = ""
26
- options.each do |flag|
27
- if not @opts[flag].nil?
28
- chars.concat(@opts[flag].scan(/./))
29
- end
30
- end
31
- length.to_i.times do
32
- result += chars.sample
33
- end
34
- result
18
+ # A randomly generated passord.
19
+ # @param options [Array] Options for the password given in strings. Available strings `number` `upletter` `downletter` `symbol`
20
+ # @param length [Integer] How long the password will be
21
+ # @return [String] Returns the Base64-encoded version of the password.
22
+ def self.cpass(options, length)
23
+ options = options != Array || options.empty? ? options : %w{number upletter downletter symbol}
24
+ length = length.is_a(Integer) && length > 0 ? length : 10
25
+ chars = []
26
+ result = ""
27
+ options.each do |flag|
28
+ if not @opts[flag].nil?
29
+ chars.concat(@opts[flag].scan(/./))
30
+ end
35
31
  end
36
-
37
- # Creates a UUID.
38
- # @return [String] The UUID
39
- def self.uuid
40
- SecureRandom.uuid
32
+ length.to_i.times do
33
+ result += chars.sample
41
34
  end
35
+ result
36
+ end
42
37
 
43
- # Encodes password in Base64.
44
- # @param pass [String] The password to be encoded
45
- # @param layers [Fixnum] The amount of layering
46
- # @return [String] Returns the Base64-encoded version of the password
47
- def self.base64(pass, layers: 1)
48
- layers.times do
49
- pass = Base64.encode64 pass
50
- end
51
- pass
52
- end
38
+ # Creates a UUID.
39
+ # @return [String] The UUID
40
+ def self.uuid
41
+ SecureRandom.uuid
42
+ end
53
43
 
54
- # Creats a SHA1 hash.
55
- # @param pass [String] The password to be encoded
56
- # @param layers [Fixnum] The amount of layering
57
- # @return [String] The SHA1 hash
58
- def self.sha1(pass, layers: 1)
59
- layers.times do
60
- pass = Digest::SHA1.hexdigest pass
61
- end
62
- pass
44
+ # Encodes password in Base64.
45
+ # @param pass [String] The password to be encoded
46
+ # @param layers [Fixnum] The amount of layering
47
+ # @return [String] Returns the Base64-encoded version of the password
48
+ def self.base64(pass, layers: 1)
49
+ layers.times do
50
+ pass = Base64.encode64 pass
63
51
  end
52
+ pass
53
+ end
64
54
 
65
- # Creats a SHA256 hash.
66
- # @param pass [String] The password to be encoded
67
- # @param layers [Fixnum] The amount of layering
68
- # @return [String] The SHA256 hash
69
- def self.sha256(pass, layers: 1)
70
- layers.times do
71
- pass = Digest::SHA256.new().update(pass).to_s
72
- end
73
- pass
55
+ # Creats a SHA1 hash.
56
+ # @param pass [String] The password to be encoded
57
+ # @param layers [Fixnum] The amount of layering
58
+ # @return [String] The SHA1 hash
59
+ def self.sha1(pass, layers: 1)
60
+ layers.times do
61
+ pass = Digest::SHA1.hexdigest pass
74
62
  end
63
+ pass
64
+ end
75
65
 
76
- # Creats a SHA384 hash.
77
- # @param pass [String] The password to be encoded
78
- # @param layers [Fixnum] The amount of layering
79
- # @return [String] The SHA384 hash
80
- def self.sha384(pass, layers: 1)
81
- layers.times do
82
- pass = Digest::SHA384.new().update(pass).to_s
83
- end
84
- pass
66
+ # Creats a SHA256 hash.
67
+ # @param pass [String] The password to be encoded
68
+ # @param layers [Fixnum] The amount of layering
69
+ # @return [String] The SHA256 hash
70
+ def self.sha256(pass, layers: 1)
71
+ layers.times do
72
+ pass = Digest::SHA256.new().update(pass).to_s
85
73
  end
74
+ pass
75
+ end
76
+
77
+ # Creats a SHA384 hash.
78
+ # @param pass [String] The password to be encoded
79
+ # @param layers [Fixnum] The amount of layering
80
+ # @return [String] The SHA384 hash
81
+ def self.sha384(pass, layers: 1)
82
+ layers.times do
83
+ pass = Digest::SHA384.new.update(pass).to_s
84
+ end
85
+ pass
86
+ end
86
87
 
87
- # Creats a SHA512 hash.
88
- # @param pass [String] The password to be encoded
89
- # @param layers [Fixnum] The amount of layering
90
- # @return [String] The SHA512 hash
91
- def self.sha512(pass, layers: 1)
92
- layers.times do
93
- pass = Digest::SHA512.new().update(pass).to_s
94
- end
95
- pass
88
+ # Creats a SHA512 hash.
89
+ # @param pass [String] The password to be encoded
90
+ # @param layers [Fixnum] The amount of layering
91
+ # @return [String] The SHA512 hash
92
+ def self.sha512(pass, layers: 1)
93
+ layers.times do
94
+ pass = Digest::SHA512.new.update(pass).to_s
96
95
  end
96
+ pass
97
+ end
97
98
 
98
- # Encodes password in Base64 encoded hash.
99
- # @param pass [String] The password to be encoded
100
- # @param layers [Fixnum] The amount of layering
101
- # @return [String] The Base64-encoded hash
102
- def self.base64hash(pass, layers: 1)
103
- layers.times do
104
- pass = Base64.encode64((HMAC::SHA1.new(pass) << 'base').digest).strip
105
- end
106
- pass
99
+ # Encodes password in Base64 encoded hash.
100
+ # @param pass [String] The password to be encoded
101
+ # @param layers [Fixnum] The amount of layering
102
+ # @return [String] The Base64-encoded hash
103
+ def self.base64hash(pass, layers: 1)
104
+ layers.times do
105
+ pass = Base64.encode64((HMAC::SHA1.new(pass) << 'base').digest).strip
107
106
  end
107
+ pass
108
+ end
108
109
 
109
- class Decode
110
+ class Decode
110
111
 
111
- # Decodes password in Base64.
112
- # @param base [String] The Base64-encoded of the original password
113
- # @return [String] Returns the decoded password
114
- def self.base64(base)
115
- Base64.decode64 base
116
- end
112
+ # Decodes password in Base64.
113
+ # @param base [String] The Base64-encoded of the original password
114
+ # @return [String] Returns the decoded password
115
+ def self.base64(base)
116
+ Base64.decode64 base
117
117
  end
118
- end
118
+ end
119
+ end
@@ -2,36 +2,38 @@ require 'base64'
2
2
  require 'digest/sha1'
3
3
  require 'digest/sha2'
4
4
  require 'hmac-sha1'
5
+
6
+ # String module
5
7
  class String
6
- # @see PassLock#base64
7
- def to_base
8
- Base64.encode64 self
9
- end
10
- alias_method :to_base64, to_base
8
+ # @see PassLock#base64
9
+ def to_base
10
+ Base64.encode64 self
11
+ end
12
+ alias_method :to_base64, to_base
11
13
 
12
- # @see PassLock#sha1
13
- def to_sha1
14
- Digest::SHA1.hexdigest self
15
- end
14
+ # @see PassLock#sha1
15
+ def to_sha1
16
+ Digest::SHA1.hexdigest self
17
+ end
16
18
 
17
- # @see PassLock#sha256
18
- def to_sha256
19
- Digest::SHA256.new().update(self).to_s
20
- end
19
+ # @see PassLock#sha256
20
+ def to_sha256
21
+ Digest::SHA256.new.update(self).to_s
22
+ end
21
23
 
22
- # @see PassLock#sha384
23
- def to_sha384
24
- Digest::SHA384.new().update(self).to_s
25
- end
24
+ # @see PassLock#sha384
25
+ def to_sha384
26
+ Digest::SHA384.new.update(self).to_s
27
+ end
26
28
 
27
- # @see PassLock#sha512
28
- def to_sha512
29
- Digest::SHA512.new().update(self).to_s
30
- end
29
+ # @see PassLock#sha512
30
+ def to_sha512
31
+ Digest::SHA512.new.update(self).to_s
32
+ end
31
33
 
32
- # @see PassLock#base64hash
33
- def to_basehash
34
- Base64.encode64((HMAC::SHA1.new(self) << 'base').digest).strip
35
- end
36
- alias_method :to_base64hash, to_basehash
37
- end
34
+ # @see PassLock#base64hash
35
+ def to_basehash
36
+ Base64.encode64((HMAC::SHA1.new(self) << 'base').digest).strip
37
+ end
38
+ alias_method :to_base64hash, to_basehash
39
+ end
@@ -1,4 +1,4 @@
1
1
  module PassLock
2
- # The version of the gem installed.
3
- VERSION = '0.0.5'
4
- end
2
+ # The version of the gem installed.
3
+ VERSION = '0.0.6'.freeze
4
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passlock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Snazzah