Class: Izokatu::Rbnacl::PrivateKey::Decrypter
- Defined in:
- lib/izokatu/rbnacl/private_key/decrypter.rb
Overview
RbNaCl private key decrypter
Constant Summary collapse
- DEFAULT_OPTIONS =
Default options for Izokatu::Rbnacl::Decrypter
{ auth_data: '' }.freeze
Constants inherited from Decrypter
Instance Attribute Summary collapse
-
#auth_data ⇒ String
readonly
Authenticated data.
-
#key ⇒ String
readonly
Key for private key encryption/decryption.
Attributes inherited from Decrypter
Attributes inherited from Decrypter
#decrypted_data, #decrypter, #encrypted_data
Instance Method Summary collapse
-
#create_decrypter! ⇒ RbNaCl::AEAD::XChaCha20Poly1305IETF
Creating decrypter instance.
-
#decrypt_data! ⇒ Hash
Decrypting data.
-
#initialize(key:, encrypted_data:, nonce:, auth_data:) ⇒ Decrypter
constructor
Initializing option for decryption.
Methods inherited from Decrypter
#import_encrypted_data!, #perform
Methods included from Callable
Constructor Details
#initialize(key:, encrypted_data:, nonce:, auth_data:) ⇒ Decrypter
Initializing option for decryption
28 29 30 31 32 |
# File 'lib/izokatu/rbnacl/private_key/decrypter.rb', line 28 def initialize(key:, encrypted_data:, nonce:, auth_data:) @key = key super(encrypted_data: encrypted_data, nonce: nonce) @auth_data = auth_data || DEFAULT_OPTIONS[:auth_data] end |
Instance Attribute Details
#auth_data ⇒ String (readonly)
Returns authenticated data.
12 13 14 |
# File 'lib/izokatu/rbnacl/private_key/decrypter.rb', line 12 def auth_data @auth_data end |
#key ⇒ String (readonly)
Returns key for private key encryption/decryption.
10 11 12 |
# File 'lib/izokatu/rbnacl/private_key/decrypter.rb', line 10 def key @key end |
Instance Method Details
#create_decrypter! ⇒ RbNaCl::AEAD::XChaCha20Poly1305IETF
Creating decrypter instance
40 41 42 |
# File 'lib/izokatu/rbnacl/private_key/decrypter.rb', line 40 def create_decrypter! @decrypter = RbNaCl::AEAD::XChaCha20Poly1305IETF.new(key) end |
#decrypt_data! ⇒ Hash
Decrypting data
50 51 52 |
# File 'lib/izokatu/rbnacl/private_key/decrypter.rb', line 50 def decrypt_data! { decrypted_data_string: decrypter.decrypt(nonce, encrypted_data, auth_data) } end |