我正在尝试使用此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开始,此功能现已捆绑到核心库中.
原文链接:https://www.f2er.com/php/133174.html这个功能(但无论如何)在核心PHP中都不可用.它不是很久以前提出的,到目前为止你只能把它作为patch.
您可以使用crypt
或hash
.
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 thatCRYPT_BLOWFISH
is better suited for password storage and should be used instead viacrypt()
.