duange051858 2013-08-29 16:55
浏览 38

哈希密码功能无法正常工作

I am having problems login users in using the below code.

It seems like when I execute my if statement with the correct user password the password entered by the user and the password in my database are not matching up. Can someone give me their input on what I am doing wrong?

$pwd = hashed password in my database

$pass = password users enter on logi page



 if ($pwd === PwdHash($pass,substr($pwd,0,9))) {



 function PwdHash($pwd, $salt = null)
{
  if ($salt === null)     {
    $salt = substr(md5(uniqid(rand(), true)), 0, SALT_LENGTH);
  }
else     {
    $salt = substr($salt, 0, SALT_LENGTH);
}
return $salt . sha1($pwd . $salt);
}
  • 写回答

2条回答 默认 最新

  • donglu1472 2013-08-29 17:08
    关注

    You should put SALT_LENGTH to your checking function as you do in your generator function. . Manually cheking are they different or the same?

    评论

报告相同问题?

悬赏问题

  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败