Skip to main content

encrypt

Function encrypt 

Source
pub fn encrypt(
    plaintext: &[u8],
    key: &Key,
    options: Option<EncryptOptions>,
) -> Result<EncryptionResult>
Expand description

Encrypt data using AEAD encryption.

Prefers XChaCha20-Poly1305 if specified, otherwise uses AES-256-GCM.

§Arguments

  • plaintext - Data to encrypt
  • key - 256-bit encryption key
  • options - Optional encryption options

§Returns

Encrypted data with algorithm, nonce, and authentication tag.