Sha256: 25971548fd9a2b1198a5a42ee5f9888621ebe88fa4210aafd9efd0c61ed93e9b

Contents?: true

Size: 413 Bytes

Versions: 4

Compression:

Stored size: 413 Bytes

Contents

require 'digest/md5'

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

      Digest::MD5.hexdigest("#{query}&key=#{JaslTenpay.key}").upcase
    end

    def self.verify?(params)
      params = Utils.stringify_keys(params)
      sign = params.delete('sign')

      generate(params) == sign
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jasl_tenpay-1.1.1 lib/jasl_tenpay/sign.rb
jasl_tenpay-1.1.0 lib/jasl_tenpay/sign.rb
jasl_tenpay-1.0.2 lib/jasl_tenpay/sign.rb
jasl_tenpay-1.0.1 lib/jasl_tenpay/sign.rb