Sha256: 56dbe7c3938d0313b2fe475e00d8f630670fe0d8e758a0ac94eb89f7cfdb0e4c
Contents?: true
Size: 842 Bytes
Versions: 4
Compression:
Stored size: 842 Bytes
Contents
module Oschadbank class MacBuilder include Constants def initialize(request_type, mac_key, request_params) @request_type = request_type @mac_key = mac_key @request_params = request_params @request_type = :auth if @request_type == :pre_auth end def build params_order = MAC_PARAMS_ORDER[@request_type] return unless params_order params_str = join_params(@request_params, params_order) digest = OpenSSL::Digest.new('sha1') OpenSSL::HMAC.hexdigest(digest, @mac_key, params_str) end private def join_params(params, params_order) parts = params_order.map do |param| value = params[param].to_s if value.empty? '-' else "#{value.length}#{value}" end end parts.join end end end
Version data entries
4 entries across 4 versions & 1 rubygems