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.

Uses XChaCha20-Poly1305 by default. AES-256-GCM is available only when explicitly selected; callers choosing it must prevent nonce reuse per key.

§Arguments

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

§Returns

Encrypted data with algorithm, nonce, and authentication tag.