Closed StringKe closed 2 weeks ago
Can you create a minimal reproducible repo for this?
Make sure to include a minimal copy of that encrypted database with the proper key in the repo.
You have been invited to my private repository. https://github.com/StringKe/bsmc-report
Here you go, change your wxFileIndex()
function to the following
index.ts:
async function wxFileIndex(path: string, password: string) {
const db = new Database(path, {
readonly: true,
verbose: function (...args: any[]) {
console.log(`SQLITE => `, ...args);
},
});
db.pragma(`cipher='sqlcipher'`);
db.pragma(`legacy = 1`);
db.pragma(`key='${password}';`);
db.pragma(`hmac_use = 1`);
db.pragma(`kdf_iter = 4000`);
db.pragma(`legacy_page_size = 1024`);
db.pragma(`hmac_algorithm = 0`);
db.pragma(`kdf_algorithm = 0`);
const tables = db.prepare(`SELECT name FROM sqlite_master WHERE type='table'`).all();
console.log(tables);
}
Output:
> npx esno src/index.ts
SQLITE => PRAGMA cipher='sqlcipher'
SQLITE => PRAGMA legacy = 1
SQLITE => PRAGMA key='49b2c71';
SQLITE => PRAGMA hmac_use = 1
SQLITE => PRAGMA kdf_iter = 4000
SQLITE => PRAGMA legacy_page_size = 1024
SQLITE => PRAGMA hmac_algorithm = 0
SQLITE => PRAGMA kdf_algorithm = 0
SQLITE => SELECT name FROM sqlite_master WHERE type='table'
[
{ name: 'WxFileIndex3' },
{ name: 'WxFileIndexDirty' },
{ name: 'WxFileIndexRefresh' },
{ name: 'WxFileIndexRegistry' },
{ name: 'WxFileIndexLinkify' },
{ name: 'WxFileIndexDownloadMigration' }
]
Your database was created with SQLCipher v1. That should be specified explicitly when using BS3MC. Next time, please make sure that you have gone through all the necessary documentation when you work with this library because it could get quite complicated. If you looked through it, you would've found this documentation on how to work with legacy SQLCipher DBs.
I've tried using the key in several ways and every time I get
SqliteError: file is not a database
.my code:
logger: