Codeigniter tank auth检查用户输入的密码

时间:2012-08-09 15:35:57

标签: codeigniter tankauth

我在我的网站上使用Tank Auth。

我试图更新他的个人资料时,我搜索了一个能检查用户是否输入了有效密码的功能。

我不明白如何从用户输入中填写与数据库中的密码相匹配的密码。

这是我的控制器代码:

            $password = $this->input->post('password');
            $hasher = new PasswordHash(
                $this->config->item('phpass_hash_strength', 'tank_auth'),
                $this->config->item('phpass_hash_portable', 'tank_auth')
            );
            $hashed_password = $hasher->HashPassword($password);

$hashed_password每次给我不同的哈希值

我不认为我应该启用phpass_hash_portable

有任何建议吗?

2 个答案:

答案 0 :(得分:2)

您需要使用Tank Auth的CheckPassword模块,而不是使用phpass的PasswordHash对其进行散列。

答案 1 :(得分:0)

您可以使用此功能检查密码:

$hasher->CheckPassword(password which has to be checked,password from database).

而不是加密自己。

注意:必须检查的密码=>是原始数据 来自数据库的密码=>来自数据库的密码。