journeyapps / node-sqlcipher

SQLCipher bindings for Node
https://journeyapps.com
BSD 3-Clause "New" or "Revised" License
206 stars 66 forks source link

Databases created are not encrypted on Linux (Manjaro 5.15.112), electron-react-boilerplate #110

Open dashDotter opened 1 year ago

dashDotter commented 1 year ago

The database is created via the following code.

export function createDatabase(filePath: string, password: string): Promise<Database> {

  return new Promise<Database>((resolve): void => {
    let database: Database = new Database(filePath, async (): Promise<void> => {
      database.serialize(function(): void {
        database.run("PRAGMA cipher_compatibility = 4");
        database.run(`PRAGMA key = '${password}'`);
      });
      database = await setupTables(database);
    });
    resolve(database);
  });
}

called somewhere else in the project via:

//....
const someAsyncFunction = async () => {
    const db = await createDatabase(pathToDbFile, password);
}
//....

The resulting file can be opened with an editor/sql viewer of choice without providing the specified password. The same code when compiled on windows however, will result in an encrypted Database.

It is used within the electron-react-boilerplate @journeyapps/sqlcipher version is 5.3.1 I tested it on manjaro 5.12 and manjaro 6.1.