2012-08-09 48 views
0

我正在使用坦克验证为我的网站。Codeigniter坦克验证检查用户输入的密码

我已经搜索了一个函数,当他试图更新他的配置文件时,它将检查用户是否输入了有效的密码。

我不明白如何散列用户输入的密码,以匹配数据库中的密码。

这里是我的控制器代码:

  $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

您需要使用Tank Auth的CheckPassword模块,而不是使用phpass的PasswordHash对其进行哈希处理。

0

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

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

,而不是你自己的加密。

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