net 6 使用 加密sqlite

用加密sqlite 使用了 sqlciphone

1、在nuget中安装 (1)microsoft.entityframeworkcore.sqlite.core  (2)sqlitepclraw.bundle_e_sqlcipher

2、设置连接字符串 在appsettings.json 里 

"ConnectionStrings": {
  "SqliteConnection": "Filename=t1.db"
}

3、在program.cs里

var sqliteBaseConnectionString = builder.Configuration.GetConnectionString("SqliteConnection") ?? throw new InvalidOperationException("Connection string 'SqliteConnection' not found.");
var sqliteConnectionString = new SqliteConnectionStringBuilder(sqliteBaseConnectionString)
{
  Mode = SqliteOpenMode.ReadWriteCreate,
  Password = "123456",

  //DataSource = "resource/t1.db", // 数据库文件路径
}.ToString();

builder.Services.AddDbContext<SqliteDbContext>(options =>
options.UseSqlite(sqliteConnectionString));

---------------------------------------------------------------------------------------------------------------

下载:https://sqlitestudio.pl/

使用SQLiteStudio(3.4.3) 连接加密数据库

1、选择数据库类型  SQLCipher

2、文件:先择相应的数据库文件

3、密码:填入123456 (上面程序设置的密码)

4、加密算法配置(SQCipher 4):

PRAGMA kdf_iter = '256000';

PRAGMA cipher_page_size = 4096;

PRAGMA cipher_hmac_algorithm = HMAC_SHA512;

PRAGMA cipher_default_kdf_algorithm = PBKDF2_HMAC_SHA512;

---------------------------------------------------------------------------------------------------

下载 DB Browser for SQLite: http://www.sqlitebrowser.org/dl/

使用 DB Browser (SQLCipher) 查看加密数据库

1、输入密码

2、SQLCipher 4 默认 

 

--------------------------------------------------------

https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/encryption?tabs=visual-studio

https://libaineu2004.blog.csdn.net/article/details/81128360?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3-81128360-blog-123866986.pc_relevant_recovery_v2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3-81128360-blog-123866986.pc_relevant_recovery_v2&utm_relevant_index=6

https://cloud.tencent.com/developer/ask/sof/1554268

https://blog.csdn.net/Backspace110/article/details/106952191

 

posted @ 2023-02-26 10:56  stone8386  阅读(329)  评论(0编辑  收藏  举报