speedmax (owner)

Revisions

gist: 182118 Download_button fork
public
Description:
money patch rails to fix bug #3144
Public Clone URL: git://gist.github.com/182118.git
Embed All Files: show embed
initializer/patch_secure_compare.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
module ActiveSupport
  class MessageVerifier
    private
      # constant-time comparison algorithm to prevent timing attacks
      def secure_compare(a, b)
        if a.respond_to?(:bytes)
          a.bytes.to_a == b.bytes.to_a
        else
          a.to_a == b.to_a
        end
      end
   end
end