Sha256: b6a07d8f45c80c3aa3d448e1519ffbb34c380ec4fd22c8cf873b73e127f60de4
Contents?: true
Size: 931 Bytes
Versions: 5
Compression:
Stored size: 931 Bytes
Contents
module Flexite class Diff class Token def initialize(string_token) @token = string_token.encode(Encoding::UTF_8) end def valid? secure_compare(Flexite.config.migration_token, @token) end def invalid? !valid? end private # Constant-time comparison algorithm to prevent timing attacks # # see Devise.secure_compare # # @param this_str [String] first value # @param that_str [String] second value # # @return [TrueClass, FalseClass] true or false # def secure_compare(this_str, that_str) return false if this_str.blank? || that_str.blank? || this_str.bytesize != that_str.bytesize this_str_bytes = this_str.unpack "C#{this_str.bytesize}" that_str.each_byte.reduce(0) do |memo, byte| memo | byte ^ this_str_bytes.shift end == 0 end end end end
Version data entries
5 entries across 5 versions & 1 rubygems