使用AES256编译System.Data.Sqlite [英] Compile System.Data.Sqlite With AES256

查看:218
本文介绍了使用AES256编译System.Data.Sqlite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在深入研究sqlite,system.data.sqlite和xerial的JDBC,以使加密的sqlite文件可同时使用这三个文件。据我了解, system.data.sqlite 使用RC4加密,而SQLCipher / Rijndael / wxSqlite可以使用AES256。

I'm knee deep in compilation for sqlite, system.data.sqlite, and xerial's JDBC trying to get an encrypted sqlite file working through all three. From my understanding, system.data.sqlite uses RC4 encryption, and SQLCipher/Rijndael/wxSqlite can use AES256.

使用该库,一个可以轻松编译Windows二进制文件以进行AES256加密。

此库通过合并 Xerial的JDBC wxsqlite3 rel = nofollow noreferrer> wxsqlite3的改进,它看起来实际上是基于上述(Rijndael)库的。

Using this library, one can easily compile Windows binaries for AES256 encryption.
This library offers Xerial's JDBC by incorporating wxsqlite3's improvements, which it looks like is actually based on the above (Rijndael's) library.

由于上述两个库几乎是相同的,并且使用相同的加密,因此它们是兼容的。我有一个支持加密的JDBC的Java项目,并且有一个已编译的sqlite3.dll和sqlite3shell.exe,可让我使用命令行来加密,读取,写入等数据库。这个sqlite dll和shell与使用JDBC创建的数据库兼容。

Because the above two libraries are close to one-and-the-same, and use the same encryption, they have been compatible. I have a working Java project with the encryption-supporting JDBC, and I have a compiled sqlite3.dll and sqlite3shell.exe that allows me to use the command line to encrypt, read, write, etc databases. This sqlite dll and shell are compatible with the databases created with the JDBC.

我有点迷惑的地方是 system.data.sqlite 与AES256一起使用。我需要使用该库,因为它使我能够使用实体框架和LINQ。我原以为这不是一项艰巨的任务,但是过去几天来,我一直在这个问题上犹豫不决。我有可加密的sqlite3 dll,如何将其与system.data.sqlite合并?

Where I'm a bit lost is getting system.data.sqlite working with AES256. I need to use this library as it affords me the ability to use Entity Framework and LINQ. I had thought it would not be such an arduous task, but I've been ramming my head into a wall for the past few days on this issue. I have the encryption-ready sqlite3 dll, how do I merge this in with system.data.sqlite?

非常感谢您的帮助。

推荐答案

如果重新定位.NET标准4.6.1+或Core,您可能需要尝试Microsoft.Data.Sqlite。只需添加2个Nuget包,即可为您提供AES256加密。顺便说一句,有付费的选项来获取AES256编译的System.Data.Sqlite。 答案中列出了一些。

If you're targeting .NET standard 4.6.1+ or Core, you may want to give Microsoft.Data.Sqlite a try. This can give you AES256 encryption by simply adding 2 Nuget Packages. By the way, there are paid options to get AES256 compiled System.Data.Sqlite. Some are listed in this answer.

如果您的项目是当前使用System.Data.Sqlite,然后转换将涉及方法&的某些搜索/替换。类名,其中很多是大写字母的区别。例如, SQLiteDataReader变为 SqliteDataReader。

If your project is currently using System.Data.Sqlite, then transitioning will involve some search/replace of method & class names, much of which is a difference in caps. For example, "SQLiteDataReader" becomes "SqliteDataReader."

另一个区别是Microsoft.Data.Sqlite在列命名方面很严格。例如,如果数据库模式将该列命名为 Datelisted,则引用该列 DateListed的命令将失败。

Another difference is that Microsoft.Data.Sqlite is strict about column naming. For example, a command that references a column named "DateListed" will fail if the database schema has that column as "Datelisted."

如果您想探索进行过渡安装2个nuget软件包:

If you want to explore making a transition install 2 nuget packages:

Install-Package Microsoft.Data.Sqlite.Core
Install-Package SQLitePCLRaw.bundle_sqlcipher

设置 SQLitePCL

SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_sqlcipher());
SQLitePCL.Batteries_V2.Init();
SQLitePCL.raw.FreezeProvider();

创建加密数据库

string error = string.Empty;
static SQLitePCL.sqlite3 sqlite
SQLitePCL.raw.sqlite3_open(dbPath, out sqlite);
SQLitePCL.raw.sqlite3_exec(sqlite, "PRAGMA key ='myPassword'", out error);
SQLitePCL.raw.sqlite3_close(sqlite);

这篇关于使用AES256编译System.Data.Sqlite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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