Sha256: 2ff52ee40caeca7ff4ec3542e94d02cc68776ae24fcf994c24ed11e5ea915e91

Contents?: true

Size: 384 Bytes

Versions: 5

Compression:

Stored size: 384 Bytes

Contents

require 'openssl'
require 'base64'

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alipay-0.7.1 lib/alipay/sign/rsa.rb
alipay-0.7.0 lib/alipay/sign/rsa.rb
alipay-0.6.0 lib/alipay/sign/rsa.rb
alipay-0.6.0.beta3 lib/alipay/sign/rsa.rb
alipay-0.6.0.beta2 lib/alipay/sign/rsa.rb