Skip to main content

is_database_encrypted

Function is_database_encrypted 

Source
pub fn is_database_encrypted<P>(path: P) -> Result<bool, Error>
where P: AsRef<Path>,
Expand description

Checks if a database file appears to be encrypted.

SQLCipher-encrypted databases have a different file header than plain SQLite. Plain SQLite databases start with “SQLite format 3\0” (16 bytes). Encrypted databases will have random-looking bytes at the start.

§Arguments

  • path - Path to the database file

§Returns

  • Ok(true) if the file exists and appears encrypted
  • Ok(false) if the file exists and appears unencrypted (plain SQLite)
  • Ok(false) if the file doesn’t exist (new database)
  • Err if there’s an I/O error reading the file