Php hash_pbkdf2不提供任何输出

Php hash_pbkdf2不提供任何输出,php,hash,passwords,pbkdf2,Php,Hash,Passwords,Pbkdf2,我正在写一段php代码,但它没有给我想要的输出 function passhash($unhashPass){ if(CRYPT_BLOWFISH != 1) { throw new Exception("bcrypt not supported in this installation.); } $salt = "test123"; $password = hash_pbkdf2 ("sha256", $unhashPass, $salt, 1, 20); echo $

我正在写一段php代码,但它没有给我想要的输出

function passhash($unhashPass){

if(CRYPT_BLOWFISH != 1) {
       throw new Exception("bcrypt not supported in this installation.);
    }
$salt = "test123";
$password = hash_pbkdf2 ("sha256", $unhashPass, $salt, 1, 20);
echo $password;
return $password;
} 
当我把unhashpass或salt的echo语句放在hash开始工作之前,但在它什么都不做之后,整个php脚本只会给我一个白色屏幕。 有人能帮我吗:)


Cheers

函数
hash_pbkdf2()
将在PHP版本5.5中引入,因此我怀疑您安装的PHP版本还不支持此函数。在调用函数之前,您需要测试是否定义了BCrypt,但是函数
hash_pbkdf2()
(基于密码的密钥派生函数)与BCrypt无关

不过,建议使用BCrypt散列密码,在PHP 5.5版中,您可以使用
password\u hash()
代替。对于早期版本,也存在一个新的解决方案

// Hash a new password for storing in the database.
// The function automatically generates a cryptographically safe salt.
$hashToStoreInDb = password_hash($password, PASSWORD_BCRYPT);

// Check if the hash of the entered login password, matches the stored hash.
// The salt and the cost factor will be extracted from $existingHashFromDb.
$isPasswordCorrect = password_verify($password, $existingHashFromDb);

是的,但是这个网站是在服务器上运行的,所以我不能将任何内容更改为php版本,但是我会尝试使用外部文件。谢谢大家!@user2156757-兼容包可能是早期PHP版本的最佳解决方案。这些只是我可以放在htmldocs中的外部库,对吗?我可能会寻找其中一个:)@user2156757-是的,它只是一个独立的php文件,只需将它复制到您的项目中。然后您可以调用函数,如答案中的示例。