Why not use AES for password encryption in PHP?

后端 未结 6 407
孤独总比滥情好
孤独总比滥情好 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:20

    If you store a password encrypted, it can be decrypted. Since many people reuse passwords across many different systems, this is a bad thing. So you use a one-way function, a cryptographic hash function - this way a password can be verified without actually being revealed.

    As Greg commented, AES is an encryption/decryption algorithm. MD5 and the SHA family are hash functions, which are the more appropriate ones to use. But steer clear of MD5 nowadays - it's not really seen as secure enough any more. Xiaoyun Wang published an effective collision attack against it in 2005, and its strength is now seen as considerably below its design strength - thus in cryptographic terms it is "broken".

    For best results, the standard is to salt and hash a password to store it - google these terms in tandem and you'll find numerous references.

提交回复
热议问题