C# 确定 SQLite 数据库文件是否经过密码加密

标签 c# sql database sqlite system.data.sqlite

是的,我知道可以尝试连接到 SQLite 数据库,然后在需要密码时使用 try-catch。这不是干净的代码。我正在寻找一种更智能的方法来确定 .sqlite 文件在尝试连接之前是否已加密。我正在为这个项目使用 System.Data.sqlite dll。

最佳答案

您必须检查 SQLite 主数据库文件本身。

摘自 The SQLite Database File Format :

1.2.4 Reserved bytes per page

SQLite has the ability to set aside a small number of extra bytes at the end of every page for use by extensions. These extra bytes are used, for example, by the SQLite Encryption Extension to store a nonce and/or cryptographic checksum associated with each page.

关于C# 确定 SQLite 数据库文件是否经过密码加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34712402/

相关文章:

python - 维基百科 SQL 转储无法使用 Python/SQLite 加载

sql - 同一个表在另一个表中的多列

c# - 用于 Fluent Interface 的嵌套 Lambda

c# - 如何使用DataContext.ExecuteCommand 获取执行后的存储过程返回值?

javascript - c# WPF Webbrowser with Highchart,来自外部源的 Javascript 不工作 "An error has occurred in the script on this page"

mysql - 我如何确定我是否在 MYSQL 中得到记录重复?

mysql - 连接到两个表之一的实体关系图

ruby-on-rails - 数据库导入后将迁移标记为已迁移

sql-server - 如何在不重复分片的情况下扩展数据库中的写入?

c# - 哪些异常类已经存在,我们什么时候使用它们?