pub fn apply_encryption(
conn: &Connection,
config: &EncryptionConfig,
) -> Result<(), Error>Expand description
Applies SQLCipher encryption to a connection.
This function configures a SQLite connection for SQLCipher encryption by:
- Setting the encryption key (PRAGMA key) - must be first operation
- Pinning SQLCipher 4.x compatibility mode
- Forcing in-memory temporary storage to avoid plaintext temp file spill
- Validating the key by reading from sqlite_master
§Arguments
conn- The SQLite connection to configureconfig- The encryption configuration containing the key
§Errors
Returns an error if:
- The key is incorrect for an existing database
- The database is corrupted
- The database is not encrypted but a key was provided