Class: Alipay::Sign::RSA2

Inherits:
Object
  • Object
show all
Defined in:
lib/alipay/sign/rsa2.rb

Class Method Summary collapse

Class Method Details

.sign(key, string) ⇒ Object



7
8
9
10
# File 'lib/alipay/sign/rsa2.rb', line 7

def self.sign(key, string)
  rsa = OpenSSL::PKey::RSA.new(key)
  Base64.strict_encode64(rsa.sign('sha256', string))
end

.verify?(key, string, sign) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/alipay/sign/rsa2.rb', line 12

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