coolman Messages: 119 Registered: April 2006 Location: Czech Republic
Experienced Member
You can check encrypted Sqlite before Open() the DB using the function
bool Sqlite::IsFileEncrypted(const char *DBfilename) {
FileIn in(DBfilename);
if (!in) {
return false;
}
String SqlVersion = "SQLite format 3";
int SqlVersionLength = SqlVersion.GetCount();
in.Seek(0);
String version = in.Get(SqlVersionLength);
in.Close();
return (!version.IsEqual(SqlVersion));
}
With combination of returned code from Open() function
...
int errCode = sqlite3db.GetErrorCode();
String errMsg = Format("[ %s&&Error: %d (%s)]", t_("Loading the database has failed!"), errCode, sqlite3db.GetErrorCodeString());
if (SQLITE_NOTADB == errCode) {
errMsg = t_("The database is encrypted but decryption failed!&[= Did you use the correct password?");
}
ErrorOK(errMsg);
...