Sha256: 084bb9e9b9527a678c31cede081342875308f181daf14d20e1cb7f67b3852cb0
Contents?: true
Size: 409 Bytes
Versions: 4
Compression:
Stored size: 409 Bytes
Contents
require 'digest/md5' module WxPay module Sign def self.generate(params) query = params.sort.map do |key, value| "#{key}=#{value}" end.join('&') Digest::MD5.hexdigest("#{query}&key=#{WxPay.key}").upcase end def self.verify?(params) params = params.dup sign = params.delete('sign') || params.delete(:sign) generate(params) == sign end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
wx_pay-0.1.0 | lib/wx_pay/sign.rb |
wx_pay-0.0.4 | lib/wx_pay/sign.rb |
wx_pay-0.0.3 | lib/wx_pay/sign.rb |
wx_pay-0.0.2 | lib/wx_pay/sign.rb |