Class: Flexpay::Signature
- Inherits:
-
Object
- Object
- Flexpay::Signature
- Defined in:
- lib/flexpay/util.rb
Class Method Summary collapse
Class Method Details
.generate_signature(http_method, host, request_uri, params, secret_key) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/flexpay/util.rb', line 7 def self.generate_signature(http_method, host, request_uri, params, secret_key) method = http_method.to_s.upcase #Place in canonical order and URI encode encoded_data = params.sort.collect {|i| i.join("=") }.join("&") data = "#{http_method}\n#{host}\n#{request_uri}\n#{modified_URL_encoding(encoded_data)}" digest = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, secret_key, data) Base64.encode64(digest).strip end |