4

我正在考虑为 PHP 应用程序支持加密的 sqlite 数据库。我正在使用 PHP 的 SQLite3 扩展,似乎它们已经支持加密方法,至少 SQLite3::__construct 允许通过加密密钥。

我无法弄清楚的是,他们在文档中谈论的是哪个加密库。通过谷歌搜索,我发现以下内容:

  • sqlcipher
  • sqlite 见
  • sqlite地穴

我不清楚的是:

  • 这些库如何与 SQLite3 集成
  • 如果它们在指定加密密钥和设置数据访问等方面彼此共享兼容性。
  • 如果我可以在我的应用程序中自动检测是否有,以及我的 SQLite3 安装支持哪个加密库,那么我的应用程序可以支持不同的加密库

很感谢任何形式的帮助!

4

4 回答 4

2

The SQLite3 library needs to be built with support for encryption. Those projects (and a few more: https://stackoverflow.com/a/5877130/502789) can be used to get an sqlite3.so/dll with encryption support.

So, the questions...

  1. They don't integrate with sqlite. They offer a replacement sqlite3 library with encryption support
  2. Vanilla SQLite3 provides the API required for encryption, but it's unimplemented. I believe SQLiteCrypt uses its own API and so won't work here (don't quote me on that).
  3. Your SQLite3 installation doesn't support it, you need to replace it with an SQLite3 library compiled with this feature (see the options I linked).

NB: I haven't used PHP + SQlite3 encryption.

于 2012-03-03T14:28:54.997 回答
1

管理员发布了一篇似乎对 SQLite 加密有用的帖子,解释了如何使用 sqlcipher http://www.basic4ppc.com/forum/basic4android-getting-started-tutorials/14965-android-database-encryption-sqlcipher-library。 html

于 2012-07-07T00:52:46.023 回答
1

据我所知,您传递给 PHP open 的密码只有在您使用的是带有加密支持的 SQLite 版本时才有效(即加密在默认构建中不起作用)。

我们已经让一些用户通过使用 SQLCipher 代码库构建 PHP 软件成功地将 SQLCipher 与 PHP 一起使用。更多信息可在此处的线程中找到:

http://groups.google.com/group/sqlcipher/browse_thread/thread/6d77e4ef2a1530d7

于 2012-03-01T15:34:47.830 回答
0

请在此处查看我的答案: https ://stackoverflow.com/a/49161716/9418360

SQLite3 有内置的加密接口。您需要在 config.m4 中启用它: -DSQLITE_HAS_CODEC=1 我已经开发了自己的基于 AES 的加密。/ext/sqlite3/libsqlite 中有一些 C 文件,它工作得很好。整个数据库文件是加密的,不需要从 PHP 发送加密数据。一旦我准备好发布我的代码,我就会更新这篇文章。干杯。

于 2018-03-07T21:56:02.600 回答