Class: Izokatu::Rbnacl::PublicKey::Encrypter
- Defined in:
- lib/izokatu/rbnacl/public_key/encrypter.rb
Overview
RbNaCl public key encrypter
Constant Summary collapse
- RBNACL_KEY_CLASSES =
RbNaCl public and private key classes
[ RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey, RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey ].freeze
Constants inherited from Encrypter
Instance Attribute Summary collapse
-
#private_key ⇒ RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey
readonly
Private key.
-
#public_key ⇒ RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey
readonly
Public key.
Attributes inherited from Encrypter
Attributes inherited from Encrypter
#clear_data, #encrypted_data, #encrypter
Instance Method Summary collapse
-
#create_encrypter! ⇒ RbNaCl::Boxes::Curve25519XSalsa20Poly1305
Initializing option for encryption.
-
#encrypt_data! ⇒ Array
Encrypting data.
-
#initialize(public_key:, private_key:, clear_data:) ⇒ Encrypter
constructor
Initializing option for encryption.
Methods inherited from Encrypter
Methods inherited from Encrypter
Methods included from Callable
Constructor Details
#initialize(public_key:, private_key:, clear_data:) ⇒ Encrypter
Initializing option for encryption
27 28 29 30 31 |
# File 'lib/izokatu/rbnacl/public_key/encrypter.rb', line 27 def initialize(public_key:, private_key:, clear_data:) @public_key = public_key @private_key = private_key super(clear_data: clear_data) end |
Instance Attribute Details
#private_key ⇒ RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey (readonly)
Returns private key.
11 12 13 |
# File 'lib/izokatu/rbnacl/public_key/encrypter.rb', line 11 def private_key @private_key end |
#public_key ⇒ RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey (readonly)
Returns public key.
9 10 11 |
# File 'lib/izokatu/rbnacl/public_key/encrypter.rb', line 9 def public_key @public_key end |
Instance Method Details
#create_encrypter! ⇒ RbNaCl::Boxes::Curve25519XSalsa20Poly1305
Initializing option for encryption
39 40 41 42 43 44 |
# File 'lib/izokatu/rbnacl/public_key/encrypter.rb', line 39 def create_encrypter! raise 'ERROR: No public key!' unless public_key raise 'ERROR: No private key!' unless private_key @encrypter = RbNaCl::Box.new(public_key, private_key) end |
#encrypt_data! ⇒ Array
Encrypting data
52 53 54 55 56 57 |
# File 'lib/izokatu/rbnacl/public_key/encrypter.rb', line 52 def encrypt_data! [ { encrypted_data_string: encrypter.encrypt(nonce, clear_data) }, { nonce: nonce } ] end |