Sha256: 8a1abfa815814d632fabf88d1f14ec229823edf7782e0c510c821ea96d9fb2ba
Contents?: true
Size: 752 Bytes
Versions: 4
Compression:
Stored size: 752 Bytes
Contents
module Qtpay module Sign def self.generate(params, options = {}) params = Utils.stringify_keys(params) key = options[:server_key] || Qtpay.server_key string = params_to_string(params) sign(key, string) end def self.verify?(params, options = {}) params = Utils.stringify_keys(params) sign_type = params.delete('sign_type') sign = params.delete('sign') string = params_to_string(params) key = options[:server_key] || Qtpay.server_key sign == sign(key, string) end def self.sign(key, string) Digest::MD5.hexdigest("#{string}#{key}") end def self.params_to_string(params) params.sort.map { |item| item.join('=') }.join('&') end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
qtpay-0.0.4 | lib/qtpay/sign.rb |
qtpay-0.0.3 | lib/qtpay/sign.rb |
qtpay-0.0.2 | lib/qtpay/sign.rb |
qtpay-0.0.1 | lib/qtpay/sign.rb |