class Izokatu::Openssl::PublicKey::RSA::Encrypter

OpenSSL public key RSA encrypter

Attributes

public_key[R]

@return [String] public key string for decryption

Public Class Methods

new(clear_data:, public_key:) click to toggle source

Initialize options for OpenSSL RSA encryption

@param clear_data (clear_data) @param public_key (public_key)

@since 0.1.0

Calls superclass method Izokatu::Encrypter::new
# File lib/izokatu/openssl/public_key/rsa/encrypter.rb, line 19
def initialize(clear_data:, public_key:)
  super(clear_data: clear_data)
  initialize_public_key!(public_key)
end

Public Instance Methods

initialize_public_key!(public_key) click to toggle source

Initialize RSA public key from public key string

@param public_key (public_key)

@return [OpenSSL:PKey::RSA] OpenSSL public key instance

@since 0.1.0

# File lib/izokatu/openssl/public_key/rsa/encrypter.rb, line 32
def initialize_public_key!(public_key)
  raise 'ERROR: No public key!' unless public_key

  @public_key = OpenSSL::PKey::RSA.new(public_key)
end

Private Instance Methods

encrypt_data!() click to toggle source

Encrypting data

@return [Array] encrypted data with empty hash in place of params

@since 0.1.0

# File lib/izokatu/openssl/public_key/rsa/encrypter.rb, line 46
def encrypt_data!
  raise 'ERROR: No public key!' unless public_key

  [{ encrypted_data_string: public_key.public_encrypt(clear_data) }, {}]
end