PHPass的正确实现 [英] Correct implementation of PHPass

查看:33
本文介绍了PHPass的正确实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PHPass 在我的应用程序中存储用户密码,因为它比 md5 或 sha1 更安全.我有一个关于如何在密码中使用盐的问题.

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';
}

但我没有看到任何使用盐的地方.根据我的阅读,我的用户表应该有一个额外的字段用于散列密码时使用的盐,但是 PHPass 的 CheckPassword 方法不需要盐?

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?

谢谢.

推荐答案

Phpass 在对密码进行哈希处理时添加盐,因此无需添加单独的盐并将其存储在数据库中.

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.

这篇关于PHPass的正确实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆