Why not use AES for password encryption in PHP?

后端 未结 6 388
孤独总比滥情好
孤独总比滥情好 2021-01-01 16:09

Everywhere I have seen people talking about storing passwords in a database, they have almost always used MD5.

What is wrong with AES, or SHA1?

6条回答
  •  一整个雨季
    2021-01-01 16:12

    Because AES encryption is symmetric. Given a password encrypted with AES and the key, you can decrypt the password. This is undesirable, because you almost always want only the owner of the password to know it and don't want to have an easy way to derive the password. The SHA and MD5 algorithms, on the other hand, perform a (mostly) one-way transformation of the password. There is no piece of information (key) that allows you to return the transformed password back to its plaintext form.

提交回复
热议问题