使用时
$t_hash = new PasswordHash(12, FALSE);
的每个实例
$passHASH = $t_hash->HashPassword($password);
即使出现相同的单词,也会返回不同的结果。例如:
$t_hash->HashPassword('test') => $2a$12$7OKS2iaFMWfTYL7sHdl9EunA90.ZdiEIXgPcpXFsqrhD3z7tk06eO
$t_hash->HashPassword('test') => $2a$12$MWtkeSMQgUU22nCjRZmV8uG8dgHByM1nvyrk7XE9bw6znK8ZDFfwy
$t_hash->HashPassword('test') => $2a$12$Dx1sYTWIZmiREyn0KYh4G.daUNsmksYiSpnUKdaHZMrELIwmlhPyW
任何人都可以帮我解决这个问题吗?执行以下代码时
$t_hash = new PasswordHash(12, FALSE);
$passwordHASH = $t_hash->HashPassword($array['pass']);
$passwordHASH = $t_hash->HashPassword($passwordHASH,$array['pass']);
print($passwordHASH."<br/>");
$passwordHASH = $t_hash->HashPassword($passwordHASH,$array['pass']);
print($passwordHASH."<br/>");
$passwordHASH = $t_hash->HashPassword($passwordHASH,$array['pass']);
print($passwordHASH."<br/>");
$passwordHASH = $t_hash->HashPassword($passwordHASH,$array['pass']);
print($passwordHASH);
返回
$2a$12$h3BLa3ytEmASpHgqVnmj4.3K5TwPPqwQG/cGHx/64KN1lqMtFZ8dC
$2a$12$x4uK46uBjv5xVstc4sR7iOrOJGPbSbWJRZIFlz9ir7ktydpYqStxO
$2a$12$r.CAy.amcVTFG.CtkTNg0eBN4HXP8tp4Yj/tsIVH7SxmK1bGjQJLS
$2a$12$8NzPVId7ReZVJJA7oWtkvuR2WKwPIUkpY/NQ2lszSH6EwdubzyIrm
答案 0 :(得分:1)
这是正确的行为,HashPassword
每次调用时都会使用随机盐,因此结果不一样。