简体   繁体   中英

Why can't I open a Sqlite database after setting a password using C# code?

I have a SQLite database. I use C# code to set its password. It all goes well with no error. However, I cannot open it using "DB Browser For Sqlite" client.

Here is my c# code:

SQLiteConnection cnn = new SQLiteConnection(Config.ConnectionString);
cnn.Open();
cnn.ChangePassword(Config.DbPassword);
cnn.Close();
cnn.Dispose();

Here is the login picture: 在此处输入图片说明

Edit: If I use DB Browser for SQLite option "Set Encryption" then it works fine in both C# code and DB Browser for SQLite.

For anyone else facing this issue, I turns out SQL uses "SQLCipher only recognizes 256-bit AES" according to this link: github.com/sqlitebrowser/sqlitebrowser/wiki/Encrypted-Databases and System.Data.SQLite; uses a different encryption. So if you just want to encrypt your SQLite DB then using System.Data.SQLite is does the job. But if you want to specifically encrypt it with SQLCipher then use SQLitePCLRaw.bundle_sqlcipher package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM