我的 PHP 网站有以下内容:
- 启用 SSL
Cookie:
session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);
传输时使用 SHA512 密码,然后是 password_hash(),最后是 PASSWORD_BCRYPT
- Mysqli 预处理语句
- 在插入/更新到 Mysql 时输入所有经过清理
- htmlentities 等..用于尽可能避免 xss。
我现在希望使用 AES_Encrypt 函数通过将要加密和解密的 $key 存储在 webroot 目录之外来加密敏感数据。
这可能会存储患者数据,我现有的是否足够安全?
问题:
How are you sanitizing the inputs when you INSERT/UPDATE? If you're using Prepared Statements, you should not escape the data manually as well.
答案:
示例:
$firstname = ucwords(filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_STRING));
最佳答案
我一直理解 不要使用 MySQL 的内置加密功能,因为静态数据(在 SQL 中)的加密点是,如果服务器受到威胁,数据不会在 [一样多] 风险。
MySQL 内置功能的问题在于它不适用于数据传入和传出“静止”状态的时间,因此可以记录任何数据的明文在 MySQL 日志中(以及存储系统上的其他地方,例如查询查找未加密,因此您可以在加密之前/之后从大量查找及其 count
结果中推断出列值)。 You can read more about this here .
Regarding encryption, you should use some tried and tested library like defuse/php-encryption.
根据我在自己关于该主题的研究中所读到的内容,Magnus 提供的链接为 defuse/php-encryption是防止 MySQL 导致您破坏数据的最佳方法之一,永远不要让 MySQL 程序/服务器看到您数据的明文值。
关于php - Mysql加密/存储敏感数据,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43833858/