首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >password_hash中的成本选项是什么?

password_hash中的成本选项是什么?
EN

Stack Overflow用户
提问于 2016-08-09 01:25:47
回答 1查看 3.4K关注 0票数 3

在PHP手册中,有许多在password_hash中使用password_hash选项的示例。下面是一些用于计算cost值的示例代码

代码语言:javascript
复制
<?php
/**
* This code will benchmark your server to determine how high of a cost you can
* afford. You want to set the highest cost that you can without slowing down
* you server too much. 8-10 is a good baseline, and more is good if your servers
* are fast enough. The code below aims for ≤ 50 milliseconds stretching time,
 * which is a good baseline for systems handling interactive logins.
 */
$timeTarget = 0.05; // 50 milliseconds 

$cost = 8;
do {
 $cost++;
 $start = microtime(true);
 password_hash("test", PASSWORD_BCRYPT, ["cost" => $cost]);
 $end = microtime(true);
} while (($end - $start) < $timeTarget);

echo "Appropriate Cost Found: " . $cost . "\n";
?>

cost是什么意思?它是用来做什么的?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-09 01:33:54

来自维基百科

代价参数指定密钥扩展迭代计数为2的幂,这是对加密算法的输入。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38840672

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档