sqlite 加密与连接

本文探讨了SQLite数据库使用System.Data.Sqlite库进行加密后导致的问题,即加密后的数据库文件只能由该库读取,无法在Navicat等其他工具中直接打开。提供了连接加密SQLite数据库的代码示例,并指出了加密文件的非标准性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

加密

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);
}

参考资料:
Open connection to SQLite secured database with navicat
资料出处:
sqlite 加密与连接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值