Sha256: 3dda5eb2b8d7f7a1dcdcd3550e4a80fd74ba8a4196e09d7a67b52212e30f4015
Contents?: true
Size: 487 Bytes
Versions: 7
Compression:
Stored size: 487 Bytes
Contents
require 'digest/md5' module WxPay module Sign def self.generate(params) key = params.delete(:key) query = params.sort.map do |key, value| "#{key}=#{value}" if value != "" && !value.nil? end.compact.join('&') Digest::MD5.hexdigest("#{query}&key=#{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
7 entries across 7 versions & 1 rubygems