v0.9.2 switched to correct version of encrypted database
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const Database = require('better-sqlite3-sqlcipher');
|
||||
const Database = require('better-sqlite3-multiple-ciphers');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const bcrypt = require('bcryptjs');
|
||||
@@ -18,9 +18,13 @@ function getDb() {
|
||||
}
|
||||
db = new Database(DB_PATH);
|
||||
if (DB_KEY) {
|
||||
// Apply encryption key — must be the very first pragma before any other DB access
|
||||
db.pragma(`key = '${DB_KEY.replace(/'/g, "''")}'`);
|
||||
console.log('[DB] Encryption key applied');
|
||||
// Use SQLCipher4 AES-256-CBC — compatible with standard sqlcipher CLI and DB Browser
|
||||
// Must be applied before any other DB access
|
||||
const safeKey = DB_KEY.replace(/'/g, "''");
|
||||
db.pragma(`cipher='sqlcipher'`);
|
||||
db.pragma(`legacy=4`);
|
||||
db.pragma(`key='${safeKey}'`);
|
||||
console.log('[DB] Encryption key applied (SQLCipher4)');
|
||||
} else {
|
||||
console.warn('[DB] WARNING: DB_KEY not set — database is unencrypted');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user