Sha256: 5f178bdc81933548927ff647920c6a4a0c777700beb668ad672eddcf7676ec68
Contents?: true
Size: 627 Bytes
Versions: 5
Compression:
Stored size: 627 Bytes
Contents
# frozen_string_literal: true module MaxExchangeApi module Helper class << self def gen_headers(payload, access_key, secret_key) encoded_payload = encode(payload) return { 'X-MAX-ACCESSKEY' => access_key, 'X-MAX-PAYLOAD' => encoded_payload, 'X-MAX-SIGNATURE' => encrypt(encoded_payload, secret_key), } end private def encode(data) Base64.strict_encode64(data.to_json) end def encrypt(data, key) OpenSSL::HMAC.digest('sha256', key, data).unpack('H*')[0] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems