wxsqlite3 does not encrypt database correct.

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
doanphong
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Jun 21, 2016 2:24 am

wxsqlite3 does not encrypt database correct.

Postby doanphong » Tue Jun 21, 2016 9:03 am

Hi all.

Im build wxwidget version 3.0.2 and wxsqlite3 3.3.1 with Visual Studio.

I have created a database with encryption wxsqlite3 . But when using other programs (ex: Navicat) to read them then receive the error message "file is encrypted or is not a database".

When i try query again with wxsqlite3 or sqlite3_shell then still query data correct.

Code: Select all

wxString dbFile = wxString();
wxString dbKey = wxString(wxT("Abc123@"));
wxString pwdQuery;

wxSQLite3Database::InitializeSQLite();
wxSQLite3Database db;

db.Open("Main.db");

string sql = "Create table test(column_a);";
string sql1 = "Insert into test values('Test data');";

db.ExecuteUpdate(sql);
db.ExecuteUpdate(sql1);

db.ReKey(dbKey);

string sqlquery = "Select * from test;";

db.Close();
   
wxSQLite3Database::ShutdownSQLite();


Pls help me.

utelle
Moderator
Moderator
Posts: 758
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxsqlite3 does not encrypt database correct.

Postby utelle » Tue Jun 21, 2016 10:18 am

doanphong wrote:Im build wxwidget version 3.0.2 and wxsqlite3 3.3.1 with Visual Studio.

I have created a database with encryption wxsqlite3 . But when using other programs (ex: Navicat) to read them then receive the error message "file is encrypted or is not a database".

There exist several incompatible encryption extensions for SQLite. That is, other programs need to explicitly support the wxSQLite3 encryption extension for being able to handle databases encrypted by wxSQLite3.

However, AFAIK Navicat does support the wxSQLite3 encryption extension. The question is, which version Navicat uses. The wxSQLite3 encryption extension comes in 2 flavors AES-128 and AES-256. Additionally there was a change in the implementation of the encryption extension in May 2014.

Maybe Navicat still uses the old wxSQLite3 encryption scheme. If that is the case it will not be able to handle encrypted databases created with a later version of the encryption extension, unless you force your version to use the old encryption scheme, too, by specifying the following define:

Code: Select all

#define WXSQLITE3_USE_OLD_ENCRYPTION_SCHEME

Regards,

Ulrich

doanphong
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Jun 21, 2016 2:24 am

Re: wxsqlite3 does not encrypt database correct.

Postby doanphong » Tue Jun 21, 2016 11:02 am

Hi Ulrich.

I 've rebuilt sqlite3 with #define WXSQLITE3_USE_OLD_ENCRYPTION_SCHEME and it worked. Sorry i bad english.

Thanks very much.

utelle
Moderator
Moderator
Posts: 758
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxsqlite3 does not encrypt database correct.

Postby utelle » Tue Jun 21, 2016 12:46 pm

doanphong wrote:I 've rebuilt sqlite3 with #define WXSQLITE3_USE_OLD_ENCRYPTION_SCHEME and it worked. Sorry i bad english.

Glad to hear that you could solve your problem. Maybe you should contact the Navicat guys and ask whether they kept the old encryption scheme on purpose.

Usually there is no problem in using the old encryption scheme. As explained in the readme file in the sqlite3 subfolder of wxSQLite3 there is only a 0.012 % chance of failure, that is, almost neglectible. However, the new encryption scheme conforms better to the interface of the SQLite3 encryption extension.

Regards,

Ulrich


Return to “wxCode”

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest