Sha256: ceae1343ce6bc24590455a3604c333090b7da923d4a6b6fbd85a4aa58ef03473

Contents?: true

Size: 500 Bytes

Versions: 2

Compression:

Stored size: 500 Bytes

Contents

require "openssl"
require "base64"

module AlipayMini
  module Sign
    class RSA2

      def self.sign(key, string)
        pkey = OpenSSL::PKey::RSA.new(key)
        digest = OpenSSL::Digest::SHA256.new

        Base64.strict_encode64(pkey.sign(digest, string))
      end

      def self.verify?(key, string, sign)
        pkey = OpenSSL::PKey::RSA.new(key)
        digest = OpenSSL::Digest::SHA256.new

        pkey.verify(digest, Base64.strict_decode64(sign), string)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alipay_mini-0.1.1 lib/alipay_mini/sign/rsa2.rb
alipay_mini-0.1.0 lib/alipay_mini/sign/rsa2.rb