Symmetric encryption and streaming cipher utilities.
Supports AES-256-GCM (authenticated), ChaCha20-Poly1305, and AES-256-CTR (streaming mode for large files/streams).
All encrypted values are self-contained (IV/nonce + tag + ciphertext,
Base64-encoded) and use :crypto.strong_rand_bytes/1 for key/IV generation.
Summary
Functions
Decrypts a value encrypted with encrypt/2. Returns {:ok, plaintext} or {:error, reason}.
Decrypts ChaCha20-Poly1305 encrypted data. Returns plaintext on success, :error on failure.
Decrypts data encrypted with AES-256-CTR streaming.
Encrypts plaintext with AES-256-GCM. Returns {:ok, ciphertext}.
Encrypts plaintext with ChaCha20-Poly1305.
Encrypts a chunk of data in streaming mode.
Finalizes a streaming encryption. Returns the final state (discard after).
Starts an AES-256-CTR encryption stream. Use with stream_encrypt/2 and stream_finalize/1.
Functions
Decrypts a value encrypted with encrypt/2. Returns {:ok, plaintext} or {:error, reason}.
Decrypts ChaCha20-Poly1305 encrypted data. Returns plaintext on success, :error on failure.
Decrypts data encrypted with AES-256-CTR streaming.
Encrypts plaintext with AES-256-GCM. Returns {:ok, ciphertext}.
Encrypts plaintext with ChaCha20-Poly1305.
Encrypts a chunk of data in streaming mode.
Finalizes a streaming encryption. Returns the final state (discard after).
Starts an AES-256-CTR encryption stream. Use with stream_encrypt/2 and stream_finalize/1.