v0.9.2 switched to correct version of encrypted database

This commit is contained in:
2026-03-13 15:30:57 -04:00
parent e02cf69745
commit 5301d8a525
7 changed files with 23 additions and 19 deletions

View File

@@ -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');
}