1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/openssl] Look up digest by name instead of constant

b28fb2f05c
This commit is contained in:
Bart de Water 2020-04-19 11:14:36 -04:00 committed by Kazuki Yamaguchi
parent 3f8665fe0e
commit 0b2c70eaa1
31 changed files with 161 additions and 171 deletions

View file

@ -31,8 +31,8 @@ module OpenSSL
# the length of the secret. Returns +true+ if the strings are identical,
# +false+ otherwise.
def self.secure_compare(a, b)
hashed_a = OpenSSL::Digest::SHA256.digest(a)
hashed_b = OpenSSL::Digest::SHA256.digest(b)
hashed_a = OpenSSL::Digest.digest('SHA256', a)
hashed_b = OpenSSL::Digest.digest('SHA256', b)
OpenSSL.fixed_length_secure_compare(hashed_a, hashed_b) && a == b
end
end