use sqlite3_key create a sqlite database file, then can't open with navicat for sqlite.
cjl3230 opened this issue · 6 comments
I created a sqlite file using the following code
sqlite3* db;
sqlite3_open("test_pwd.db", &db);
const char* pwd = "123456";
sqlite3_key(db, pwd, strlen(pwd));
char* pStr = nullptr;
sqlite3_exec(db, createSQL, nullptr, nullptr, &pStr);
sqlite3_close(db);
Then I opened the file with Navicat and used the password '123456', but it was prompted that this is not a sqlite database file!How can I open it by navicat?
The default cipher scheme used by SQLite3 Multiple Ciphers is ChaCha20-Poly1305 (aka chacha20). However, to my knowledge Navicat uses the cipher scheme wxSQLite3 AES-128 (aka aes128cbc). Therefore you have to explicitly select the cipher scheme that should be used, namely aes128cbc. A similar question was asked about 2 years ago here: wxSQLite3 issue #57.
Thank you, although I still don't know how to open it in Navicat, but I understand the cause of the problem.
Well, in the meantime I confirmed that Navicat supports the cipher scheme aes128cbc (which is the cipher scheme that was in use in wxSQLite3 for a long time, until support for other cipher schemes was added).
If you want to create a new database file that is compatible with Navicat, you have to explicitly select the cipher scheme. There are 2 methods to accomplish that:
- Use the URI form for the database file name, like
file:db-file-name.db3?cipher=aes128cbc
in thesqlite3_open
function, and then set the chosen password with functionsqlite3_key
. - Use only the database file name in function
sqlite3_open
, use functionsqlite3_exec
to execute the cipher scheme selection with SQL statementPRAGMA cipher='aes128cbc';
, and then set the chosen password with functionsqlite3_key
.
To open the database file in Navicat you create a new connection by selecting the type Existing Database File
, entering the database file name, and then switching to the Advanced
tab to activate the option Encrypted
. On opening the connection you will be asked for the password, unless you chose to save it in Navicat.
Thank you very much, let me try
Well, in the meantime I confirmed that Navicat supports the cipher scheme aes128cbc (which is the cipher scheme that was in use in wxSQLite3 for a long time, until support for other cipher schemes was added).
If you want to create a new database file that is compatible with Navicat, you have to explicitly select the cipher scheme. There are 2 methods to accomplish that:
- Use the URI form for the database file name, like
file:db-file-name.db3?cipher=aes128cbc
in thesqlite3_open
function, and then set the chosen password with functionsqlite3_key
.- Use only the database file name in function
sqlite3_open
, use functionsqlite3_exec
to execute the cipher scheme selection with SQL statementPRAGMA cipher='aes128cbc';
, and then set the chosen password with functionsqlite3_key
.To open the database file in Navicat you create a new connection by selecting the type
Existing Database File
, entering the database file name, and then switching to theAdvanced
tab to activate the optionEncrypted
. On opening the connection you will be asked for the password, unless you chose to save it in Navicat.
Both methods are ok, the test is successful, thank you
Since this "issue" is in fact not a real issue with the library, but nevertheless probably of interest for other users, I'm going to convert it into a "discussion".