Closed cezarsmpio closed 9 months ago
Sorry for the delayed response.
Unfortunately the
try...catch
I put inside theprepareDatabase
method doesn't throw any error, it actually passes, the error happens when it tries to execute a query on the lifecycle of the application.
This is expected behavior since the pages are decrypted only when you query any data.
Is there a recommended way to check if the database is encrypted already? So I can choose to either run .key or .rekey?
Unfortunately, the only method is to try to decrypt and look for any errors. There's no dedicated way to check the encryption status.
I am closing this issue since no further solutions are available. Feel free to reopen if you have any updates.
Hey @m4heshd , thanks for your reply!
Shouldn't .key
work seamlessly then? It should encrypt/decrypt automagically? Just based on documentation :)
I found a particular solution to migrate existing users to a new database, thank you!
Shouldn't
.key
work seamlessly then? It should encrypt/decrypt automagically? Just based on documentation :)
It follows the behavior of SQLite's own SEE for compatibility.
Just took a look at your code again. Need to verify something. Can you try the same code with key
PRAGMA instead of the key()
function?
Hey @m4heshd same behavior either using .key or pragma key.
@cezarsmpio Sorry for not responding sooner. Another issue opened recently made me remember what exactly is happening here. Please take a look at https://github.com/m4heshd/better-sqlite3-multiple-ciphers/issues/88#issuecomment-1998680385.
Hello everyone, great work on this library. I have the following case, existing databases and first run databases. According to the documentation of
.key
it says:But it's not working as expected I guess? It works fine if I run
.rekey
before.I currently use
typeorm
andElectron
with an Express server and this is my code:The error I get is:
Unfortunately the
try...catch
I put inside theprepareDatabase
method doesn't throw any error, it actually passes, the error happens when it tries to execute a query on the lifecycle of the application.If I only use:
This is the error I get:
Is there a recommended way to check if the database is encrypted already? So I can choose to either run
.key
or.rekey
?Thank you!