lib/oschadbank/mac_builder.rb in oschadbank-0.1.3 vs lib/oschadbank/mac_builder.rb in oschadbank-0.1.4
- old
+ new
@@ -1,9 +1,9 @@
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
@@ -15,13 +15,17 @@
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)
+ OpenSSL::HMAC.hexdigest(digest, packed_key, params_str)
end
private
+
+ def packed_key
+ [@mac_key].pack('H*')
+ end
def join_params(params, params_order)
parts = params_order.map do |param|
value = params[param].to_s
if value.empty?