Correct implementation of PHPass

纵饮孤独 提交于 2019-12-01 06:00:58

问题


I'm using PHPass to store users passwords in my application because it's more secure than md5 or sha1. I have a question about how I would use a salt with the passwords.

From what I gathered, I use it like this when you insert a user:

$pwdHasher = new PasswordHash(8, false);
$hash = $pwdHasher->HashPassword($input_password);

and then when you check the users details on login, you do:

$pwdHasher = new PasswordHash(8, FALSE);
if ($pwdHasher->CheckPassword($input_password, $hash_from_db)) {
    echo 'password correct';
} else {
    echo 'wrong credentials';
}

But I see nothing there that uses a salt. From what I've read, my user table should have an extra field for a salt that is used when hashing the password, but the CheckPassword method of PHPass doesn't take a salt?

Thanks.


回答1:


Phpass adds a salt when it hashes the password so there's no need to add a separate salt and store it in your database.



来源:https://stackoverflow.com/questions/8674430/correct-implementation-of-phpass

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!