utelle / wxsqlite3

wxSQLite3 - SQLite3 database wrapper for wxWidgets (including SQLite3 encryption extension)
http://utelle.github.io/wxsqlite3
Other
598 stars 181 forks source link

How to open a db encrypted by Navicat. #57

Closed netsesame2 closed 5 years ago

netsesame2 commented 5 years ago

I've a sqlite db, encrypted by Navicat for Sqlite. However, I don't know how to open it in wxsqlite3's open function.

Please help.

utelle commented 5 years ago

According to the Navicat documentation the default encryption method used by Navicat is wxSQLite3 AES 128-Bit - the default scheme used by wxSQLite3 up to version 3.5.9. The default wxSQLite3 encryption scheme was changed in version 4.0.0 to ChaCha20; that is, if you use a recent version of the wxSQLite3 encryption extension (compiled with default settings) you have to explicitly specify the cipher scheme. I.e., use the cipher URI parameter when specifying the database file name:

'file:your_navicat_database_file.db?cipher=aes128cbc'

Of course, you also have to specify the correct password (key= URI parameter or PRAGMA key= SQL command, or key parameter of the Open method of the wxSQLite3Database class) to successfully open your Navicat database file.

If you use the wxSQLite3 wxWidgets wrapper classes, you may pass a wxSQLite3CipherAes128 class instance to the Open method instead of using the cipher URI parameter.

However, Navicat also supports to exchange its SQLite DLL, thus to change the supported encryption method(s). If your Navicat database file was not created using the default encryption method (wxSQLite3 AES 128-Bit), then you will have to find out first, which encryption scheme was used and whether it is an encryption scheme supported by wxSQLite3.

netsesame2 commented 5 years ago

Thanks much. It's resolved.

BTW: Another way is to build with CODEC_TYPE=CODEC_TYPE_AES128 macro defined.

utelle commented 5 years ago

Sure, setting a different compile time default is also an option. It depends on the actual needs what's the most convenient solution.