encrypt

Function encrypt 

Source
pub fn encrypt(
    key: &[u8; 32],
    plaintext: &[u8],
    nonce: &[u8; 12],
) -> Result<Vec<u8>>
Expand description

Encrypt data with AES-256-GCM.

§Arguments

  • key - 32-byte encryption key
  • plaintext - Data to encrypt
  • nonce - 12-byte nonce (must be unique per encryption with same key)

§Returns

Ciphertext with appended authentication tag (plaintext.len() + 16 bytes)