Reputation: 363
I am new to hashes password storage. Can someone point of what I might be doing wrong. I'm using specially PHP, not C or any deviation of C.
Storing Hash:
password_hash()
function with an algorithm like sha-512
, and a cost factor.pbkdf2
key deviation function.Retrieving Hash:
password_verify
function.If someone could post a correct solution that would be much obliged.
Upvotes: 2
Views: 96
Reputation: 718
Why bother with while() loops if you can just use the build-in options?
$password = $_POST['password'];
$hash = password_hash($password,PASSWORD_DEFAULT, array('cost' => 12));
echo $hash;
This is the correct way to do it. And to verify the password all you have to do is the following.
if(password_verify($password, $hash)){
//valid password
}
Upvotes: 2