Sha256: 0659f87cfaa27331875d873b642bfb7d9d5811432c1b443f42a5b846c9091604

Contents?: true

Size: 433 Bytes

Versions: 1

Compression:

Stored size: 433 Bytes

Contents

require 'openssl'
require 'base64'

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

      def self.verify?(pubkey, string, sign)
        rsa = OpenSSL::PKey::RSA.new(pubkey)
        rsa.verify('sha1', Base64.strict_decode64(sign), string.force_encoding("utf-8"))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ll_pay-0.3.0 lib/ll_pay/sign/rsa.rb