我正在使用password_hash进行密码加密.但是有一个奇怪的问题,password_hash花费很长时间.这是一个示例代码.
这段代码将耗费1秒以上.是正常吗
这段代码将耗费1秒以上.是正常吗
<?PHP $startTime = microtime(TRUE); $password='123456'; $cost=13; $hash=password_hash($password,PASSWORD_DEFAULT,['cost' => $cost]); password_verify($password,$hash); $endTime = microtime(TRUE); $time = $endTime - $startTime; echo $time; ?>
结果是:1.0858609676361
运行在
3v4l这似乎完全正常.
原文链接:https://www.f2er.com/php/131223.html密码哈希不是你想要的优化.用Leigh on the hash
documentation:
If you are hashing passwords etc for security,speed is not your friend. You should use the slowest method.
Slow to hash means slow to crack and will hopefully make generating things like rainbow tables more trouble than it’s worth.