Class: Izokatu::Openssl::PublicKey::RSA::Decrypter
- Defined in:
- lib/izokatu/openssl/public_key/rsa/decrypter.rb
Overview
OpenSSL public key RSA decrypter
Instance Attribute Summary collapse
-
#private_key ⇒ String
readonly
Private key string for decryption.
Attributes inherited from Decrypter
#decrypted_data, #decrypter, #encrypted_data
Instance Method Summary collapse
-
#decrypt_data! ⇒ Hash
private
Decrypting data.
-
#initialize(encrypted_data:, private_key:) ⇒ Decrypter
constructor
Initialize options for OpenSSL RSA decryption.
-
#initialize_private_key!(private_key) ⇒ OpenSSL:PKey::RSA
private
Initialize RSA private key from private key string.
Methods inherited from Decrypter
#import_encrypted_data!, #perform
Methods included from Callable
Constructor Details
#initialize(encrypted_data:, private_key:) ⇒ Decrypter
Initialize options for OpenSSL RSA decryption
19 20 21 22 |
# File 'lib/izokatu/openssl/public_key/rsa/decrypter.rb', line 19 def initialize(encrypted_data:, private_key:) super(encrypted_data: encrypted_data) initialize_private_key!(private_key) end |
Instance Attribute Details
#private_key ⇒ String (readonly)
Returns private key string for decryption.
10 11 12 |
# File 'lib/izokatu/openssl/public_key/rsa/decrypter.rb', line 10 def private_key @private_key end |
Instance Method Details
#decrypt_data! ⇒ Hash (private)
Decrypting data
46 47 48 |
# File 'lib/izokatu/openssl/public_key/rsa/decrypter.rb', line 46 def decrypt_data! { decrypted_data_string: private_key.private_decrypt(encrypted_data) } end |
#initialize_private_key!(private_key) ⇒ OpenSSL:PKey::RSA (private)
Initialize RSA private key from private key string
34 35 36 37 38 |
# File 'lib/izokatu/openssl/public_key/rsa/decrypter.rb', line 34 def initialize_private_key!(private_key) raise 'ERROR: No private key!' unless private_key @private_key = OpenSSL::PKey.read(private_key) end |