加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP – hash_pbkdf2函数

发布时间:2020-12-13 22:39:07 所属栏目:PHP教程 来源:网络整理
导读:我正在尝试使用此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($h
我正在尝试使用此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;

我收到此错误:致命错误:调用未定义的函数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().

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读