Skip to content

Commit

Permalink
Changes per heartcombo#21
Browse files Browse the repository at this point in the history
  • Loading branch information
jefftrudeau committed Jun 16, 2022
1 parent 483034b commit 0bc8ea7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/devise/encryptable/encryptors/pbkdf2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ module Encryptors
class Pbkdf2 < Base
def self.compare(encrypted_password, password, stretches, salt, pepper)
value_to_test = self.digest(password, stretches, salt, pepper)
ActiveSupport::SecurityUtils.fixed_length_secure_compare(encrypted_password, value_to_test)
Devise.secure_compare(encrypted_password, value_to_test)
end

def self.digest(password, stretches, salt, pepper)
hash = OpenSSL::Digest::SHA512.new
hash = OpenSSL::Digest.new('SHA512').new
OpenSSL::KDF.pbkdf2_hmac(
password,
password.to_s,
salt: "#{[salt].pack('H*')}#{pepper}",
iterations: stretches,
hash: hash,
length: hash.digest_length,
).unpack('H*')[0]
).unpack1('H*')
end
end
end
Expand Down

0 comments on commit 0bc8ea7

Please sign in to comment.