是的,我知道可以尝试连接到 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/