PHP and SQL Hashing Help: What am I doing wrong?

后端 未结 1 359
有刺的猬
有刺的猬 2020-12-20 09:01

First off, I am fairly new to coding in general so the idea of hashing is slightly confusing. Essentially, I am trying to hash a password in order to store it in a database

相关标签:
1条回答
  • 2020-12-20 09:46

    "password column's length is what? if it's anything less than 60, mysql failed on you silently. 9 times out of 10, that's what the problem is. If so, then you'll need to start all over again by clearing your db and create a new hash. – Fred -ii- 13 mins ago"

    which I was right about all along:

    @Fred Well it looks like having the column length being 45 was a bad idea and that was my only problem. Thanks for the help, not entirely sure how this site works so I don't know how to give you rep or anything."

    As per the manual on the password_hash() function:

    http://php.net/manual/en/function.password-hash.php

    PASSWORD_DEFAULT - Use the bcrypt algorithm (default as of PHP 5.5.0). Note that this constant is designed to change over time as new and stronger algorithms are added to PHP. For that reason, the length of the result from using this identifier can change over time. Therefore, it is recommended to store the result in a database column that can expand beyond 60 characters (255 characters would be a good choice).

    0 讨论(0)
提交回复
热议问题