Skip to main content

open_db

Function open_db 

Source
pub fn open_db(path: &Path, master_key: Option<&[u8; 32]>) -> Result<Db>
Expand description

Open the DB. If master_key is Some, SQLCipher is unlocked with PRAGMA key; otherwise the DB is opened unencrypted (the Phase 1 path, kept for tests and --no-master-passphrase runs).

huddle 0.7.11: after PRAGMA key we run a sentinel query that forces SQLCipher to actually try to decrypt a page. A wrong master key (typo on the prompt) used to surface as a cryptic “file is not a database” error from a downstream CREATE TABLE; we now catch it here and return a clean “wrong master passphrase” message.