如何在.Net中使用SQLCipher [英] How to use SQLCipher in .Net

查看:187
本文介绍了如何在.Net中使用SQLCipher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用C#(winform)读取SQLCipher数据库并找到一个开源项目 SQLitePCL ,但是我没有找到这种用法的示例,并且文档也不多.有没有朋友用过这个东西,您能提供一些例子来帮助我吗?

I want to use C# (winform) to read an SQLCipher database and find an open source project SQLitePCL, but I have not found examples of this use, and the documentation is not a lot. Have any friends used this thing, can you provide some examples to help me?

谢谢!

推荐答案

这将适用于winforms,wpf,asp.net,xamarin.android,xamarin.ios,UWP和任何其他.net项目,因为这是跨平台的,平台库:

This will work for winforms, wpf, asp.net, xamarin.android, xamarin.ios, UWP and any other .net project since this is a cross-platform library:

由Frank A. Krueger"sqlite-net-pcl"安装nuget.

Install nuget by Frank A. Krueger "sqlite-net-pcl".

使用他的 github页面上的教程.

现在,一旦我们有了数据库和所有东西.如何加密新创建的数据库或打开加密的数据库?

Now, once we have database and all the stuff. How to encrypt newly created database or open encrypted database?

通过Eric Sink添加nuget:"SQLitePCLRaw.bundle_sqlcipher"

Add nuget by Eric Sink: "SQLitePCLRaw.bundle_sqlcipher"

在代码中创建SQLiteConnection的地方指定加密密钥:

In the code, where you create SQLiteConnection specify encryption key:

connection = new SQLiteConnection(dbPath, openFlags: SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.Create);
connection.Query<int>("PRAGMA key=xzy1921");

就是这样.其余的将如同未加密一样工作.

That's it. The rest will work as if it was not crypted.

这篇关于如何在.Net中使用SQLCipher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆