Expand description
enc_file — password-based authenticated encryption for files.
Highlights
- Passwords are never stored; keys are derived with Argon2id (salt + stored params).
- Authenticated encryption via XChaCha20-Poly1305 (default) or AES-256-GCM-SIV.
- Versioned binary header + CBOR payload. Optional ASCII armor for transport.
- Streaming mode for very large files (constant memory; configurable chunk size).
- Library API is pure (no prompts/logging). CLI sits on top.
Safety notes
- The crate is not audited or reviewed! Protects data at rest. Does not defend against compromised hosts/side channels.
Structs§
- Encrypt
Options - Options for encryption.
- KdfParams
- Tunable KDF parameters (mem_kib in KiB).
Enums§
- AeadAlg
- Supported AEAD algorithms.
- EncFile
Error - Library error type (no panics for expected failures).
- HashAlg
- Common hashing algorithms your library supports.
- KdfAlg
- Supported password KDFs.
Constants§
- DEFAULT_
CHUNK_ SIZE - Default chunk size for streaming (1 MiB).
Functions§
- decrypt_
bytes - Decrypt full file bytes into plaintext.
- decrypt_
file - Decrypt a file from disk. If
output
isNone
, strips “.enc” or uses “.dec”. - encrypt_
bytes - Encrypt a whole buffer and return the full file bytes (header + ciphertext).
- encrypt_
file - Encrypt a file to disk. If
output
isNone
, appends “.enc”. Useopts.stream = true
to enable streaming mode (seeencrypt_file_streaming
). - encrypt_
file_ streaming - Encrypt a file in streaming mode (constant memory).
- hash_
bytes - Hash a byte slice and return the raw digest bytes.
- hash_
bytes_ keyed_ blake3 - Keyed BLAKE3 hash (32-byte key). Only for BLAKE3 — other algorithms ignore keys or use HMACs.
- hash_
file - Hash a file (streaming) and return the raw digest bytes.
- hash_
file_ keyed_ blake3 - Keyed BLAKE3 file hash (streaming).
- load_
keymap - Load a key map using a password.
- looks_
armored - save_
keymap - Save a key map using a password (0600 perms on Unix).
- to_
hex_ lower - Helper to hex-encode (lower-case) for display or logs.
Type Aliases§
- KeyMap
- An encrypted key map: name -> raw 32-byte key (opaque).