bcrypt_hmac 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dc8ded37446060c52250bd5b78d9192b692a6ae
4
- data.tar.gz: e74a7a2c83e4d54b0d58a663f50fec0a685a25e7
3
+ metadata.gz: 53e5c61a141fbf3019c321afbbea126a717e5af4
4
+ data.tar.gz: 243bb2fa6f55407c897c49355d5b76578800f4eb
5
5
  SHA512:
6
- metadata.gz: e251ea5c2ae86722e37ebcb857736e4591c1a8b2d80ca6b31140cce51057870903166d3aa9cc0ced0917433512878f8b5ccff98f381b30325656740d8d522413
7
- data.tar.gz: f9b152d4eed9407a807014a1edfce5ef50b6554467d9ed8024bee5806179c5052bbe2b3df324ca85c8de99847f8875f9a915b31701b98f72e7a8db1976c5d0eb
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
- sanitized_bcrypt_hash = ruby_sanitize(encrypted_password)
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
- correct_password == proposed_password
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
@@ -1,3 +1,3 @@
1
1
  module BcryptHmac
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
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.2
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-17 00:00:00.000000000 Z
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: