dtr32787 2017-04-06 14:37
浏览 165
已采纳

使用AES_ENCRYPT的最佳做法是什么?它的安全性如何?

I have been asked to do some research on how form submission data can be encrypted and ensure that it is stored securely in a database. The form submission will contain personal details about employees and these must be kept secure.

I have come across AES_ENCRYPT() during my research and have managed to apply this function so that it stores the data successfully in the database.

Example SQL statement I used:

"INSERT INTO employee (firstname) VALUES (AES_ENCRYPT('$name', '$encryption_key'))"

However, I have very limited knowledge in this area and am not sure if this is sufficient enough protection to prevent the data being hacked. What level of security does this provide? Is there anything that I have missed or another technique I could use to improve my implementation?

Additionally, I have stored the encryption key in a separate PHP file but I do not know what the recommended way to store it is. Any advice on this would be much appreciated.

Sorry if this question is vague or quite broad. I am a complete beginner in this area. I am happy to provide more information if it is needed.

  • 写回答

1条回答 默认 最新

  • duanlidi1051 2017-04-06 15:18
    关注

    AES (Rijndael) crypto is pretty doggone secure. In practice, unless your data is tremendously valuable, you can consider it secure. Unless some actor with vast resources decides they want to crack your encryption, nobody will.

    But it's symmetric. It uses the same key to encrypt and decrypt stuff. So, you can consider it to be as secure as your key.

    Your key is insecure. If a cybercreep cracks the server running your php code, they immediately get access to your key. And that gives them access to your encrypted data. And they have a bright neon road sign saying "here's the data I think is sensitive."

    Don't forget that security depends on the weak link. Generally it's considered smarter to use your money and time to secure your server, rather than use symmetric encryption on a few columns of a dbms. In other words, with respect, you're probably wasting your time doing this column based encryption.

    If you absolutely must encrypt data at rest, you should consider using an asymmetric (public / private key) cryptosystem. Encrypt stuff using the public key, and keep the private key on an airgapped secure system in case you need to decrypt some data.

    Your example (first name) isn't sensitive enough to be worth this trouble.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?