class Izokatu::Rbnacl::PublicKey::Encrypter
RbNaCl public key encrypter
Constants
- RBNACL_KEY_CLASSES
RbNaCl public and private key classes
Attributes
private_key[R]
@return [RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey] private key
public_key[R]
@return [RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey] public key
Public Class Methods
new(public_key:, private_key:, clear_data:)
click to toggle source
Initializing option for encryption
@param clear_data (clear_data
) @param public_key
(public_key
) @param private_key
(private_key
)
@since 0.1.0
Calls superclass method
Izokatu::Rbnacl::Encrypter::new
# 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
Public Instance Methods
create_encrypter!()
click to toggle source
Initializing option for encryption
@return [RbNaCl::Boxes::Curve25519XSalsa20Poly1305] encrypter instance
@since 0.1.0
# 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!()
click to toggle source
Encrypting data
@return [Array] encrypted data with decrypter params
@since 0.1.0
# File lib/izokatu/rbnacl/public_key/encrypter.rb, line 52 def encrypt_data! [ { encrypted_data_string: encrypter.encrypt(nonce, clear_data) }, { nonce: nonce } ] end