我试图过渡到Blowfish认证系统。忍受我,我不是密码学家,我对Blowfish的理解还没有完成。Bycript /河豚和盐与现有的认证系统
当前设置使用sha1和盐。盐为每个用户生成并存储在数据库中。它归结为:
$salt = $this->getSalt($username);
$hash = sha1($password . $salt);
if ($hash == $hashInDB)
{
// user is authenticated, set session id etc ...
}
的getSalt()
方法获取存储在数据库中指定用户的盐。
现在,如果我理解正确的一切,隐窝我应该做的事情:
$salt = '$2a$07$' . $this->getSalt($username) . '$';
$hash = crypt($password, $salt);
if ($hash == crypt($password, $saltInDB))
{
// The user is authenticated, set session id etc..
}
为了澄清,对第二个例子中$saltInDB
变量,就像是'“$ 2A $ $ 07 arandomsaltcreatedatregistration $”的值。
- 我在做对吧?