Module: Adyen::Encoding

Defined in:
lib/adyen/encoding.rb

Class Method Summary collapse

Class Method Details

.gzip_base64(message) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/adyen/encoding.rb', line 13

def self.gzip_base64(message)
  sio = StringIO.new
  gz  = Zlib::GzipWriter.new(sio)
  gz.write(message)
  gz.close
  Base64.encode64(sio.string).gsub("\n", "")
end

.hmac_base64(hmac_key, message) ⇒ Object



8
9
10
11
# File 'lib/adyen/encoding.rb', line 8

def self.hmac_base64(hmac_key, message)
  digest = OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), hmac_key, message)
  Base64.encode64(digest).strip
end