Sha256: 8140a04f1329869febe11dabb41b7fe72f16fb71c015c0ecc0b64caeca5fb4e5

Contents?: true

Size: 398 Bytes

Versions: 14

Compression:

Stored size: 398 Bytes

Contents

require 'openssl'
require 'base64'

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

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

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
alipay-0.17.0 lib/alipay/sign/rsa.rb
alipay-0.16.0 lib/alipay/sign/rsa.rb
alipay-0.15.2 lib/alipay/sign/rsa.rb
alipay-0.15.1 lib/alipay/sign/rsa.rb
alipay-0.15.0 lib/alipay/sign/rsa.rb
yl_alipay-0.15.3 lib/alipay/sign/rsa.rb
yl_alipay-0.15.2 lib/alipay/sign/rsa.rb
alipay-0.14.0 lib/alipay/sign/rsa.rb
alipay-0.13.0 lib/alipay/sign/rsa.rb
alipay-0.12.0 lib/alipay/sign/rsa.rb
alipay-0.11.0 lib/alipay/sign/rsa.rb
alipay-0.10.0 lib/alipay/sign/rsa.rb
alipay-0.9.0 lib/alipay/sign/rsa.rb
alipay-0.8.0 lib/alipay/sign/rsa.rb