encrypt

Function encrypt 

Source
pub fn encrypt(
    key: &SessionKey,
    nonce: &[u8; 24],
    aad: &[u8],
    plaintext: &[u8],
) -> Result<Vec<u8>, CryptoError>
Available on crate feature crypto only.
Expand description

Encrypt plaintext using XChaCha20-Poly1305.

§Arguments

  • key - 32-byte session key
  • nonce - 24-byte nonce (constructed from epoch, direction, counter)
  • aad - Additional authenticated data
  • plaintext - Data to encrypt

§Returns

Ciphertext with appended 16-byte Poly1305 tag