bcrypt_hmac 0.1.2 → 0.1.3
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/lib/bcrypt_hmac.rb +2 -15
- data/lib/bcrypt_hmac/version.rb +1 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e5c61a141fbf3019c321afbbea126a717e5af4
|
4
|
+
data.tar.gz: 243bb2fa6f55407c897c49355d5b76578800f4eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ccae915ad329175af1c2dc3b7c53f394de02b4aa4f200c1ee015dff507b54bc91433778525878c611f982ab714db041920710354e579e2a176558bd61a769f8
|
7
|
+
data.tar.gz: 58145ee3cf4580fe858caa98bd3e1075eeee3a8dd9d811b54277a8ff2e77c3f3e9aeb59c76941d3d0d1b58a32105f1e7b6f6a737699fcef71e5abc9db021ef16
|
data/lib/bcrypt_hmac.rb
CHANGED
@@ -17,25 +17,12 @@ module BcryptHmac
|
|
17
17
|
|
18
18
|
def self.compare(encrypted_password, password, _stretches = nil,
|
19
19
|
_salt = nil, pepper = nil)
|
20
|
-
|
21
|
-
correct_password = BCrypt::Password.new(sanitized_bcrypt_hash)
|
20
|
+
saved_password = BCrypt::Password.new(encrypted_password)
|
22
21
|
proposed_password = prepare_for_bcrypt(password, pepper.to_s)
|
23
22
|
|
24
|
-
|
23
|
+
saved_password == proposed_password
|
25
24
|
end
|
26
25
|
|
27
|
-
# bcrypt-ruby doesn't support the '2y' prefix in hashes generated in php and
|
28
|
-
# other languages. '2y' has to be replaced with '2a' in order to recognize
|
29
|
-
# these hashes in ruby. See http://stackoverflow.com/a/20981781/1545518
|
30
|
-
def self.ruby_sanitize(bcrypt_hash)
|
31
|
-
if bcrypt_hash.starts_with?('$2y')
|
32
|
-
bcrypt_hash.sub('$2y', '$2a')
|
33
|
-
else
|
34
|
-
bcrypt_hash
|
35
|
-
end
|
36
|
-
end
|
37
|
-
private_class_method :ruby_sanitize
|
38
|
-
|
39
26
|
def self.prepare_for_bcrypt(password, hmac_key)
|
40
27
|
Base64.encode64(sha256_hash(password, hmac_key))
|
41
28
|
end
|
data/lib/bcrypt_hmac/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcrypt_hmac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ben lamothe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|
@@ -155,4 +155,3 @@ summary: Devise BCrypt + SHA256-HMAC Encryptor
|
|
155
155
|
test_files:
|
156
156
|
- spec/bcrypt_hmac_spec.rb
|
157
157
|
- spec/spec_helper.rb
|
158
|
-
has_rdoc:
|