如何将敏感数据安全地存储在MySQL数据库中? [英] How can I store sensitive data securely in a MySQL database?

查看:171
本文介绍了如何将敏感数据安全地存储在MySQL数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我正在工作的公司提供就业申请。我已经得到它来防止SQL注入和一些XSS技术。我的主要问题是保护敏感信息,如SSN和地址,因为公司需要为销售人员的税收制定1099个表格。



我不知道如何做这个部分,但是我应该加密一切,然后在进入MySQL数据库时解密它。

解决方案

这是一个过度的简单的答案,应该使用一粒盐,作为大多数关于安全性的答案:




  • 使用SSL无处不在。 >


  • 使用安全加密密钥




加密数据,您可以使用 BLOB 字段,并使用MySQL的内置加密功能。例如:

 更新mytable set myfield = AES_ENCRYPT('some value',SHA2('your secure secret key',512)) ; 

如果您希望在应用程序代码中进行加密/解密,请查看PHP的 Mcrypt 功能。




  • 加密用户输入

  • 存储在数据库中

  • 取出后解密



这绝对不是一个完整的指南,但它是一个开始,而不是没有做任何事情。



您可以通过 https://security.stackexchange.com/ 了解更多信息


I am making an employment application for a company I am working for. I've got it to protect against SQL injection and some XSS techniques. My main issue is keeping sensitive information secured, like SSN and address, because the company needs that to make 1099 forms for the salesmen's taxes.

I don't know how to do this part, but should I encrypt everything and then decrypt it when it gets into the MySQL database?

解决方案

This is an overly simplified answer and should be taken with a grain of salt, as most answers about security:

  • Use SSL everywhere.

  • Use a secure encryption key

For storage of encrypted data, you could use a BLOB field, and use MySQL's built in encryption functions. Example:

update mytable set myfield = AES_ENCRYPT('some value', SHA2('your secure secret key', 512));

If you prefer to do the encryption/decryption in the application code, take a look at PHP's Mcrypt functions.

  • Encrypt the user input
  • Store in the database
  • Decrypt it after fetching it

This is by no means a complete guide, but it's a start and better than doing nothing.

You may be able to learn more on https://security.stackexchange.com/

这篇关于如何将敏感数据安全地存储在MySQL数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆