mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Don't encode in secure_compare for speedup
Hex encoding is base 16 which makes the original input twice as big. With this change less time need to be spent in fixed_length_secure_compare.
This commit is contained in:
parent
00690b27e5
commit
c76a8c72d5
1 changed files with 1 additions and 1 deletions
|
@ -24,7 +24,7 @@ module ActiveSupport
|
|||
# The values are first processed by SHA256, so that we don't leak length info
|
||||
# via timing attacks.
|
||||
def secure_compare(a, b)
|
||||
fixed_length_secure_compare(::Digest::SHA256.hexdigest(a), ::Digest::SHA256.hexdigest(b)) && a == b
|
||||
fixed_length_secure_compare(::Digest::SHA256.digest(a), ::Digest::SHA256.digest(b)) && a == b
|
||||
end
|
||||
module_function :secure_compare
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue