Sha256: bdb51e8681b00601244d27098a7ceca73c407b7b9a844e179ac435419e2934d9

Contents?: true

Size: 554 Bytes

Versions: 2

Compression:

Stored size: 554 Bytes

Contents

module Braintree
  module Digest # :nodoc:
    def self.hexdigest(string)
      _hmac_sha1(Configuration.private_key, string)
    end

    def self._hmac_sha1(key, message)
      key_digest = ::Digest::SHA1.digest(key)
      inner_padding = "\x36" * 64
      outer_padding = "\x5c" * 64
      0.upto(19) do |i|
        inner_padding[i] ^= key_digest[i]
        outer_padding[i] ^= key_digest[i]
      end
      inner_hash = ::Digest::SHA1.digest(inner_padding + message.to_s)
      ::Digest::SHA1.hexdigest(outer_padding + inner_hash)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
braintree-1.0.1 lib/braintree/digest.rb
braintree-1.0.0 lib/braintree/digest.rb