[Request]: Allow empty encryption key
What do you need?
Thank you for the amazing library - I’ve been using it with SQLCipher encryption on both Android and iOS without issues.
I’ve enabled SQLCipher in my package.json
"op-sqlite": {
"sqlcipher": true
}
In my use case, I work with two database files. One of them is intentionally not encrypted, so I open it like this:
this.db = SQLite.open({
name: DATABASE_NAME,
location: location ?? undefined,
encryptionKey: '',
});
// PRAGMA references: https://www.zetetic.net/sqlcipher/sqlcipher-api/#cipher_plaintext_header_size
await this.db.execute('PRAGMA cipher_plaintext_header_size = 32;');
// the rest ...
This worked perfectly in version 15.0.7 — I could open the database file in a DB client without specifying an encryption key, as expected for a normal SQLite file.
After upgrading to 15.1.1, the app hangs and the terminal logs the following error:
Encryption key is missing for SQLCipher ,
I believe this originates from:
https://github.com/OP-Engineering/op-sqlite/blob/573221c18b2292b372a60481cc9fc9134e9d6879/cpp/OPSqlite.cpp#L72
Would it be possible to allow an empty string ('') as a valid encryptionKey?
The TypeScript type definition is:
encryptionKey?: string | undefined
So it seems undefined should represent “no key provided,” while an empty string should be treated as a valid (explicit) choice.
Could the C++ implementation distinguish between undefined/null and an empty string, and accept the empty string as intended?
Thanks again for the great work!
Ah, probably a regression I will take care of it. Thanks for pointing it out.