PHP-hash_pbkdf2 函数

标签 php security hash password-protection

我正在尝试使用此 php 函数执行一个散列密码的函数:http://be.php.net/manual/en/function.hash-pbkdf2.php .

代码如下:

$hash_algo = "sha256";
$password = "password";
$salt = "salt";
$iterations = 1;
$length = 1;
$raw_output = false;

$hash = hash_pbkdf2($hash_algo, $password, $salt, $iterations ,$length ,$raw_output);

echo $hash;

我收到此错误: fatal error :调用未定义的函数 hash_pbkdf2()。

函数怎么可以未定义???

PS:我的变量的所有值都是为了测试功能而设置的。显然盐不会是“盐”等

最佳答案

编辑:从 PHP 5.5.0 开始,此函数现已捆绑到核心库中。


此函数在核心 PHP 中不可用(无论如何)。它是不久前提出的,到目前为止你只能以 patch 的形式获得它。 .

您可以使用 crypthash反而。 crypt 实际上是在 hash_pbkdf2 documentation 中建议的:

Caution
The PBKDF2 method can be used for hashing passwords for storage (it is NIST approved for that use). However, it should be noted that CRYPT_BLOWFISH is better suited for password storage and should be used instead via crypt().

关于PHP-hash_pbkdf2 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11965708/

相关文章:

php - 无法将数据从url插入到php中的数据库

security - HTTPS 将我重定向到另一个网站

arrays - 什么时候返回数组或散列,什么时候只返回引用?

php - Crypt() 函数的河豚盐长度?

php - 您不能在 laravel 中序列化或反序列化 PDO 实例

PHP CRC32 长度输出

security - 使用某些应用程序,即使在防火墙或 NAT 之后,数据包如何出去?

asp.net - 保护 ASP.NET Web 目录中的文件夹

arrays - 如何在给定键数组的情况下快速过滤散列?

PHP crypt 产生不同的结果