相当于php 5.4的password_hash? [英] password_hash equivalent for php 5.4?
本文介绍了相当于php 5.4的password_hash?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用安装了PHP 5.5的XAMPP开发了我的网站。我只知道我的主机只有php 5.4(不能更新到5.5)。我的问题是我不能使用新的PHP 5.5 password_hash()
功能。有没有一种等同的方法来处理php 5.4的salt?
I developed my site using XAMPP with php 5.5 installed. I just realize that my host only has php 5.4 (cannot update to 5.5 yet). My problem is that I cannot use the new php 5.5 password_hash()
feature. Is there an equivalent method for hashing with salt for php 5.4?
有没有办法让这个等价的代码(下面)在php 5.4中工作?
Is there a way to get this equivalent code (below) to work in php 5.4?
$options = [
'salt' => uniqid(mt_rand(), true),
'cost' => 12
];
$hash = password_hash($mypassword, PASSWORD_DEFAULT, $options);
推荐答案
使用 password_compat 。它是一个向后兼容的库,用于模拟 password_hash()
在旧版本的PHP(5.3.7 +)中。
Use password_compat. It's a backward compatible library to emulate password_hash()
in older versions of PHP (5.3.7+).
这篇关于相当于php 5.4的password_hash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文