Sha256: be5eb11b9b9ccd29c64ba9425f88d74c5baf70c5c90d7534cf4b1a4a0551f415

Contents?: true

Size: 424 Bytes

Versions: 1

Compression:

Stored size: 424 Bytes

Contents

require 'digest/md5'

module Alipay
  module Sign
    def self.generate(params)
      query = params.sort.map do |key, value|
        "#{key}=#{value}"
      end.join('&')

      Digest::MD5.hexdigest("#{query}#{Alipay.key}")
    end

    def self.verify?(params)
      params = Utils.symbolize_keys(params)
      params.delete(:sign_type)
      sign = params.delete(:sign)

      generate(params) == sign
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alipay-0.0.1 lib/alipay/sign.rb