Sha256: 227177292ef345dd8ef234620a0e2af71ba781e1e33c250f7bf66b31f82c1f17

Contents?: true

Size: 454 Bytes

Versions: 8

Compression:

Stored size: 454 Bytes

Contents

require 'openssl'

module Wayforpay
  class EncryptField
    attr_reader :keys, :attrs

    def initialize(keys, attrs)
      @keys, @attrs = keys, attrs
    end

    def self.call(keys, attrs = {})
      new(keys, attrs).call
    end

    def call
      OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('md5'), Wayforpay.encrypt_secret_key, signature_string)
    end

    def signature_string
      attrs.values_at(*keys).compact.join(';')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wayforpay-0.1.7 lib/wayforpay/encrypt_field.rb
wayforpay-0.1.6 lib/wayforpay/encrypt_field.rb
wayforpay-0.1.5 lib/wayforpay/encrypt_field.rb
wayforpay-0.1.4 lib/wayforpay/encrypt_field.rb
wayforpay-0.1.3 lib/wayforpay/encrypt_field.rb
wayforpay-0.1.2 lib/wayforpay/encrypt_field.rb
wayforpay-0.1.1 lib/wayforpay/encrypt_field.rb
wayforpay-0.1.0 lib/wayforpay/encrypt_field.rb