Define the encryption requirement
“Encrypt the database” hides several separate questions:
- Must the file remain SQLite-compatible?
- Are the WAL, temporary files, result caches, backups, and index checkpoints covered?
- Does the application use a passphrase, a random key, or an external KMS?
- Must equality or range filters work without a full decrypt-first scan?
- How are keys rotated and how does rotation recover after a crash?
- What happens when the key is missing or wrong?
Encryption at rest protects stolen storage. It does not replace OS permissions, application authorization, TLS, backups, or endpoint security.
Option families
| Option | SQLite compatibility | Licensing / model | Primary reason to choose it |
|---|---|---|---|
| SQLite SEE | Official SQLite extension | Commercial license from SQLite authors | Official integration and support |
| SQLCipher | SQLite-compatible encrypted database | Open-source core with commercial offerings | Established encrypted SQLite ecosystem |
| Encrypted SQLite forks/codecs | Varies by implementation and version | Varies | Specific platform, language, or licensing fit |
| MongrelDB | None; different engine and file format | MIT or Apache-2.0 | Encryption integrated with WAL, columnar runs, hybrid indexes, and SQL |
What MongrelDB encrypts
MongrelDB encrypts sorted-run page payloads with AES-256-GCM. Encrypted tables also use frame-level AES-256-GCM for WAL segments and encrypt result-cache files. A passphrase is derived through Argon2id and HKDF, while high-entropy raw keys can skip the passphrase derivation step. HashiCorp Vault Transit can wrap the database root key externally.
Each run has its own data-encryption key wrapped by the database key hierarchy. Keys held in memory use zeroizing wrappers. If required key material is unavailable, open fails closed.
let db = Db::create_encrypted(
"./mydb",
schema,
1,
"my-secret-passphrase"
)?;Losing the passphrase or root key makes the data unrecoverable. That is expected cryptographic behavior, so key backup and restore testing belong in the database runbook.
Encryption and search are separate features
Ordinary page encryption protects stored bytes but requires the trusted process to decrypt data for general query execution. MongrelDB columns marked ENCRYPTED_INDEXABLE additionally derive deterministic equality tokens and order-preserving range tokens. Those tokens can narrow candidates without decrypting every row first.
This is not free secrecy. Equality tokens can reveal repeated values and frequency. Order-preserving range tokens reveal ordering. Use this mode only when the query requirement justifies that leakage; use ordinary encrypted columns when it does not.
Decision checklist
- If the application must keep SQLite files and APIs, remove non-SQLite engines from the shortlist.
- Test the exact SQLite features and extensions your application uses.
- Verify WAL, journal, temporary-file, backup, and crash-recovery coverage.
- Measure on deployment hardware with encryption enabled.
- Document key generation, storage, rotation, loss, and incident recovery.
- Test a wrong key and an unavailable KMS; both should fail safely.
- Run restore drills before production data exists.
MongrelDB Viewer
Viewer can open Direct databases with a passphrase or connect through an authenticated MongrelDB server. Follow its security guidance before using production roots.
Mongrel by VisorCraft
Use Mongrel when encrypted MongrelDB work sits beside SQLite and other database systems, terminals, containers, Kubernetes, and APIs.