cryptainer
Tiny encrypted byte array container for Rust.
cryptainer encrypts arbitrary bytes with AES-256-GCM using a key derived from a password with Argon2id. It can also save and load encrypted data from files when the std feature is enabled.
Features
- Password-based encryption with Argon2id
- AES-256-GCM authenticated encryption
no_stdsupport by default withalloc- Optional zeroization support
- File helpers behind
std
Usage
Encrypt bytes
use encrypt_data;
let mut rng = rng;
let data = encrypt_data?;
Decrypt bytes
use ;
let mut rng = rng;
let encrypted = encrypt_data?;
let plaintext = decrypt_data?;
Save and load files
use ;
let mut rng = rng;
let data = encrypt_data?;
save_file?;
let plaintext = decrypt_file?;
Data format
Encrypted output is stored as:
salt (16 bytes) || nonce (12 bytes) || ciphertext
API
encrypt_data(password, plaintext, rng) -> Result<CryptData, CryptError>decrypt_data(data, password) -> Result<Vec<u8>, CryptError>save_file(file_path, data) -> Result<(), CryptError>(std only)decrypt_file(file_path, password) -> Result<Vec<u8>, CryptError>(std only)
Features
std(default): enables file I/O and standard library integrationzeroize: zeroizes derived key material when available
License
MIT