-
Hello: /* function of open a datebase with password */
bool SQLite3DB::OpenDb(const char *dbName, const char *pw)
{
int nResult = sqlite3_open(dbName, &db);
nResult = sqlite3_key(db, pw, strlen(pw));
.......
}
/* function of reset password for a datebase*/
bool SQLite3DB::SetDbPassword(const char *pw)
{
if (sqlite3_rekey(db, pw, strlen(pw)) == SQLITE_OK)
return true;
else
return false;
} The problem is, when I call the function of "sqlite3_key", it always returns 0 (nResult is always 0), no matter the password (pw value) is correct or not. While the function of "sqlite3_rekey" returns the value of 0 if the password is correct(for "sqlite3_key" function) and returns Nonzero value if the password is wrong. Please give me some suggestion on how to determine whether the datebase password is correct or not by call "sqlite3_key" function. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Well, this is by design. The function
If you want to check whether the given password is correct or not, you have to issue an SQL command that actually accesses the database (like for example
This is not surprising, because
As said |
Beta Was this translation helpful? Give feedback.
Well, this is by design. The function
sqlite3_key
does not check whether the database is actually encrypted or not. This is documented in the description of the official SQLite Encryption Extension (SEE) - and this project does not change the behaviour. Here is the relevant quote from the documentation:If you…