node-sqlcipher icon indicating copy to clipboard operation
node-sqlcipher copied to clipboard

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

Open dashDotter opened this issue 2 years ago • 0 comments

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.

dashDotter avatar May 31 '23 18:05 dashDotter