Sha256: a6297c424b9061d643cb41bbed97ed0a9d86703e9b3cd455a6ad4d946f4051a4
Contents?: true
Size: 750 Bytes
Versions: 1
Compression:
Stored size: 750 Bytes
Contents
# coding: utf-8 module ChanPay module Sign module RSA def self.sign(key, hash) content = link_hash(hash) rsa = OpenSSL::PKey::RSA.new(key) Base64.strict_encode64(rsa.sign('sha1', content)) end def self.verify?(key, hash, sign) content = link_hash(hash) rsa = OpenSSL::PKey::RSA.new(key) rsa.verify('sha1', Base64.strict_decode64(sign), content) end private def self.link_hash(hash) hash.delete_if do |key, value| key == :Sign || key == :SignType || value.nil? || value == '' end values = [] hash.sort.to_h.each{|k,v| values << "#{k}=#{v}" } values.join("&") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chan_pay-0.1.0 | lib/chan_pay/sign/rsa.rb |