Sha256: 8019526ad234547f15c148ccec6812bf5552d5331aa80fda1d05d377645f7aea
Contents?: true
Size: 725 Bytes
Versions: 14
Compression:
Stored size: 725 Bytes
Contents
module Braintree module Digest # :nodoc: def self.hexdigest(private_key, string) _hmac_sha1(private_key, string) end def self.secure_compare(left, right) return false unless left && right left_bytes = left.unpack("C*") right_bytes = right.unpack("C*") return false if left_bytes.size != right_bytes.size result = 0 left_bytes.zip(right_bytes).each do |left_byte, right_byte| result |= left_byte ^ right_byte end result == 0 end def self._hmac_sha1(key, message) key_digest = ::Digest::SHA1.digest(key) sha1 = OpenSSL::Digest::Digest.new("sha1") OpenSSL::HMAC.hexdigest(sha1, key_digest, message.to_s) end end end
Version data entries
14 entries across 14 versions & 1 rubygems