Class: Izokatu::Openssl::PublicKey::RSA::Encrypter
- Defined in:
- lib/izokatu/openssl/public_key/rsa/encrypter.rb
Overview
OpenSSL public key RSA encrypter
Constant Summary
Constants inherited from Encrypter
Instance Attribute Summary collapse
-
#public_key ⇒ String
readonly
Public key string for decryption.
Attributes inherited from Encrypter
#clear_data, #encrypted_data, #encrypter
Instance Method Summary collapse
-
#encrypt_data! ⇒ Array
private
Encrypting data.
-
#initialize(clear_data:, public_key:) ⇒ Encrypter
constructor
Initialize options for OpenSSL RSA encryption.
-
#initialize_public_key!(public_key) ⇒ OpenSSL:PKey::RSA
Initialize RSA public key from public key string.
Methods inherited from Encrypter
Methods included from Callable
Constructor Details
#initialize(clear_data:, public_key:) ⇒ Encrypter
Initialize options for OpenSSL RSA encryption
19 20 21 22 |
# 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 |
Instance Attribute Details
#public_key ⇒ String (readonly)
Returns public key string for decryption.
10 11 12 |
# File 'lib/izokatu/openssl/public_key/rsa/encrypter.rb', line 10 def public_key @public_key end |
Instance Method Details
#encrypt_data! ⇒ Array (private)
Encrypting data
46 47 48 49 50 |
# 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 |
#initialize_public_key!(public_key) ⇒ OpenSSL:PKey::RSA
Initialize RSA public key from public key string
32 33 34 35 36 |
# 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 |