You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm trying to use this software to be able to us encryption for sqlite databases.
I'm trying to use database encryption with QT. I made it build already (at least the sqlite part + encryption). The wxWidgets stuff I don't really need.
So here is my problem.
Whenever I use rekey it fails to change the key.
I simply open a database. If it is not encrypted it will be encrypted and if it is already encrpted it will be decrypted. At least this is how it should be but it is not. If a new unencrypted DB is created it works fine but if I load the DB again after the encrption I get an error that the DB is corrupted or encrypted e´ven though I set the correct password with sqlite3_key(...).
I don't really get it. Am I missing something?
The text was updated successfully, but these errors were encountered:
The culprit is most probably your function isDbEncrypted(), for which you didn't show the code.
For an existing encrypted database the call to sqlite3_key has to be the very first action after opening the database connection. I suspect that isDbEncrypted() performs some SQL and returns false if that fails, but then it is already too late to call sqlite3_key.
If my suspicion is correct, then you would have to first close the database connection, reopen it, and then call sqlite3_key with the correct password. Alternatively you could read the first 16 bytes of the database files. If they are equal to the zero-terminated string SQLite format 3, then the file is an unencrypted SQLite database file; otherwise it is an encrypted database file or not a database file at all.
BTW, if the database file is unencrypted and you want to encrypt (rekey) it, then you don't need to call sqlite3_key with an empty key first. Just call sqlite3_rekey with the new password.
Hi,
I'm trying to use this software to be able to us encryption for sqlite databases.
I'm trying to use database encryption with QT. I made it build already (at least the sqlite part + encryption). The wxWidgets stuff I don't really need.
So here is my problem.
Whenever I use rekey it fails to change the key.
I simply open a database. If it is not encrypted it will be encrypted and if it is already encrpted it will be decrypted. At least this is how it should be but it is not. If a new unencrypted DB is created it works fine but if I load the DB again after the encrption I get an error that the DB is corrupted or encrypted e´ven though I set the correct password with sqlite3_key(...).
I don't really get it. Am I missing something?
The text was updated successfully, but these errors were encountered: