instance method
secure_compare
Ruby on Rails 4.0.13
Since v2.3.18 Last seen in v4.1.16 PrivateSignature
secure_compare(a, b)
constant-time comparison algorithm to prevent timing attacks
Parameters
-
areq -
breq
Source
# File activesupport/lib/active_support/message_verifier.rb, line 53
def secure_compare(a, b)
return false unless a.bytesize == b.bytesize
l = a.unpack "C#{a.bytesize}"
res = 0
b.each_byte { |byte| res |= byte ^ l.shift }
res == 0
end
Defined in activesupport/lib/active_support/message_verifier.rb line 53
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::MessageVerifier