sqlite 加密与连接 - zLulus/My_Note GitHub Wiki
加密
SQLiteConnection cnn = new SQLiteConnection($"Data Source = {sqliteFilePath}");
cnn.Open();
cnn.ChangePassword("your password");
cnn.Close();
连接加密数据库
System.Data.Sqlite uses a non standard encryption files encrypted by it are only read by system.data.sqlite
System.Data.Sqlite使用非标准的加密方式加密文件,所以只能由System.Data.Sqlite文件读取。
->加密后的sqlite数据库无法在Navicat中打开。
连接代码
public static SQLiteConext CreateConnection(string fileName, string password = "")
{
string connectionString = $"Data Source ={fileName}";
SQLiteConnection sqlLiteConnection = new SQLiteConnection(connectionString);
if (!string.IsNullOrEmpty(password))
{
sqlLiteConnection.SetPassword(password);
}
return new SQLiteConext(sqlLiteConnection);
}