Sha256: 60c08ac7594a38525e63cedcc3c565cbd2b34bafa02608ca4e1453819a2debfa

Contents?: true

Size: 455 Bytes

Versions: 2

Compression:

Stored size: 455 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('md5', string.force_encoding('utf-8')))
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ll_pay-0.5.0 lib/ll_pay/sign/rsa.rb
ll_pay-0.4.0 lib/ll_pay/sign/rsa.rb