Sha256: 724e726a3d69081f60c4952a09577c0ad17bc3f89a2ab556bb14c33a9455dc29

Contents?: true

Size: 403 Bytes

Versions: 7

Compression:

Stored size: 403 Bytes

Contents

require 'openssl'
require 'base64'

module Alipay
  module Sign
    class RSA2
      def self.sign(key, string)
        rsa = OpenSSL::PKey::RSA.new(key)
        Base64.strict_encode64(rsa.sign('sha256', string))
      end

      def self.verify?(key, string, sign)
        rsa = OpenSSL::PKey::RSA.new(key)
        rsa.verify('sha256', Base64.strict_decode64(sign), string)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
alipay-0.17.0 lib/alipay/sign/rsa2.rb
alipay-0.16.0 lib/alipay/sign/rsa2.rb
alipay-0.15.2 lib/alipay/sign/rsa2.rb
alipay-0.15.1 lib/alipay/sign/rsa2.rb
alipay-0.15.0 lib/alipay/sign/rsa2.rb
yl_alipay-0.15.3 lib/alipay/sign/rsa2.rb
yl_alipay-0.15.2 lib/alipay/sign/rsa2.rb