Self Encryption
A file content self-encryptor that provides convergent encryption on file-based data. It produces a DataMap
type and several chunks of encrypted data. Each chunk is up to 4MB in size and has an index and a name (SHA3-256 hash of the content), allowing chunks to be self-validating.
Installation
Core Concepts
DataMap
Holds the information required to recover the content of the encrypted file, stored as a vector of ChunkInfo
(list of file's chunk hashes). Only files larger than 3 bytes (3 * MIN_CHUNK_SIZE) can be self-encrypted.
Chunk Sizes
MIN_CHUNK_SIZE
: 1 byteMAX_CHUNK_SIZE
: This is actually adjustable, but defaults to 1 MiB, we use 4 MiB on the Network (before compression)MIN_ENCRYPTABLE_BYTES
: 3 bytes
Streaming Operations (Recommended)
Streaming File Encryption
Streaming File Decryption
In-Memory Operations (Small Files)
Basic Encryption/Decryption
Chunk Store Implementations
In-Memory Store
Disk-Based Store
Error Handling
The library provides an Error
enum for handling various error cases:
Best Practices
Use streaming operations (
streaming_encrypt_from_file
andstreaming_decrypt_from_storage
) for large filesUse basic
encrypt
/decrypt
functions for small in-memory dataImplement proper error handling for chunk store operations
Verify chunks using their content hash when retrieving
Use parallel operations when available for better performance
Last updated