Php 密码散列中的成本选项是什么?

Php 密码散列中的成本选项是什么?,php,php-password-hash,Php,Php Password Hash,在PHP手册中,有许多示例使用了password\u hash中的cost选项。下面是一些用于计算成本的好值的示例代码: <?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 muc

在PHP手册中,有许多示例使用了
password\u hash
中的
cost
选项。下面是一些用于计算
成本的好值的示例代码:

<?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";
?>

成本
是什么意思?这是干什么用的?

密钥设置阶段可能成本高昂的原因是它在2个工作时间内运行。由于密码散列通常与用户登录系统等常见任务相关联,因此在安全性和性能之间找到正确的平衡非常重要。使用高功因数会使执行暴力攻击变得异常困难,但会给系统带来不必要的负载

发件人:

cost参数将密钥扩展迭代计数指定为 二的幂,这是加密算法的输入


那么,问题是什么;您不了解手册中的哪些内容?在安全性和性能方面找到平衡的成本使用