【发布时间】:2012-07-21 04:39:33
【问题描述】:
而且我需要保护我的网上商店中的某些区域以供管理员使用。 问题是用户的身份验证:salt + hash 失败。
这是我创建密码的代码(使用 PHP5.x):
$salt = rand(0, 999999999999);<br>
$passEncr = sha1($pass1 + $salt);
这个变量 $passEncr 连同它的盐一起被插入到数据库中。
在登录页面我有以下检查:
$password = $_POST['password']; // hash+salt in the database
$storedSalt = $row['salt']; // salt from database<br>
if (sha1($password + $storedSalt) == $row['password'])
现在我遇到的问题是某些哈希值似乎是相同的。 如果我尝试使用字母数字密码登录,我会成功,无论该密码的内容是什么。 完整登录检查:http://pastebin.com/WjVnQ4aF
谁能解释一下我做错了什么?
【问题讨论】: