简体   繁体   English

使用C#代码设置密码后,为什么不能打开Sqlite数据库?

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

I have a SQLite database. 我有一个SQLite数据库。 I use C# code to set its password. 我使用C#代码设置其密码。 It all goes well with no error. 一切顺利,没有错误。 However, I cannot open it using "DB Browser For Sqlite" client. 但是,我无法使用“用于Sqlite的数据库浏览器”客户端打开它。

Here is my c# code: 这是我的C#代码:

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. 编辑:如果我将DB Browser用于SQLite选项“设置加密”,则它在C#代码和DB Browser对于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; 对于面临此问题的其他人,我发现SQL根据此链接使用“ SQLCipher仅识别256位AES”:github.com/sqlitebrowser/sqlitebrowser/wiki/Encrypted-Databases和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. 因此,如果您只想加密SQLite数据库,则使用System.Data.SQLite即可。 But if you want to specifically encrypt it with SQLCipher then use SQLitePCLRaw.bundle_sqlcipher package. 但是,如果要使用SQLCipher对其进行专门加密,请使用SQLitePCLRaw.bundle_sqlcipher程序包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用C#打开受密码保护的SQLite 3数据库 - Can't open a password protected SQLite 3 database with C# 在 C# 中设置和更改 SQLite 数据库密码 - Setting and changing SQLite database password in C# 为什么在 Visual Studio for C# 上启动控制台应用程序后无法编写任何代码? - Why can't I write any code after starting a console application on Visual Studio for C#? 为什么我不能在C#数据库中创建表? - Why I can't create a table in my database in C#? C#,SQlite:多次打开/关闭文件后,无法打开SQLite数据库文件 - C#, SQlite: Unable to open SQLite database files after opening/closing them many times 如何在C#中使用密码打开访问数据库? - how to open access database with password in C#? 无法将记录插入数据库 C# SQLite - Can't insert the record to database C# SQLite 通过代码将密码设置为Entity Framework 6上的Sqlite2数据库 - Setting the password by code to a Sqlite2 database on Entity Framework 6 如何使用dbContext WPF c#在数据库sqlite中添加图像? - How can I add an image in my database sqlite using dbContext WPF c#? 为什么我不能使用C#将数组绑定到依赖项属性? - Why can't I binding a array to a dependencyproperty using c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM