What function to use to hash passwords in MySQL?

前端 未结 5 1995
忘了有多久
忘了有多久 2020-12-19 00:53

I have a user table in my mysql database that has a password column. Currently, I use the MD5 algorithm to hash the users\' password for storage in the database. Now I like

5条回答
  •  离开以前
    2020-12-19 01:44

    This question is 7 years old. In that time we have progressed in computing to where MD5 and SHA1 are now easily broken by modern computers. These should be avoided now.

    With PHP 5.5 came the introduction of password_hash, which uses the far more secure bcrypt algorithm. While MySQL can encrypt/decrypt bcrypt, it's a terrible solution because you're not only adding a potentially large computation load to your database layer, but the unhashed password could be stored in your logs

    Under no circumstances should a plain text password hit MySQL, even if at the query level. Otherwise you risk writing the passwords to log (query log, general log, slow query log, etc). Which is horrific. So no, don't even bother...

提交回复
热议问题