Sha256: 630fbafba8ae702e429b0c71b53a14f162d2641a078ccba584ab2ec24efbcb83
Contents?: true
Size: 623 Bytes
Versions: 1
Compression:
Stored size: 623 Bytes
Contents
require 'base64' require 'openssl' module Bifubao module Sign def self.to_sign_data(params) params.sort.map do |key, value| "#{key}#{value}" end.join('') end def self.generate(params) Base64.encode64(Bifubao.private_key.sign(OpenSSL::Digest::SHA1.new, to_sign_data(params))) end def self.verify?(params) params = Bifubao::Utils.stringify_keys(params) params.delete '_signature_sha1_' sign = params.delete('_signature_') Bifubao::OFFICIAL_PUBLIC_KEY.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(sign), to_sign_data(params)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bifubao-0.0.1 | lib/bifubao/sign.rb |