PHP - hash_pbkdf2函数 [英] PHP - hash_pbkdf2 function
问题描述
我试图做一个函数来使用这个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中还没有(还有)。这是不久前提出的,到目前为止,您只能将其作为补丁 。 您可以使用 警告 I'm trying to do a function to hash passwords with this php function: http://be.php.net/manual/en/function.hash-pbkdf2.php. Here is the code: I got this error: Fatal error: Call to undefined function hash_pbkdf2(). How can the function be undefined??? PS: All the values of my variables are set just for testing the function. Obviously the salt will not be "salt", etc. EDIT: As of This function is not (yet anyway) available in core PHP. It was proposed not that long ago and so far you can only get it as a patch. You can use Caution
这篇关于PHP - hash_pbkdf2函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
crypt
或 hash
来代替。
crypt
实际上是在 hash_pbkdf2
文档:
PBKDF2方法可用于散列存储密码(NIST已批准使用该密码)。但是,应该注意 CRYPT_BLOWFISH
更适合于密码存储,应该通过 crypt()
来使用。
$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;
PHP 5.5.0
this function is now bundled into the core library.
crypt
or hash
instead.
crypt
is actually suggested in hash_pbkdf2
documentation:
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()
.