我已经有一个网络应用程序,我已使用
加密了所有密码哈希::化妆($字符串);
在核心php中相当于什么,这将有助于我的Android开发人员与我的应用程序同步。我尝试使用哈希和密码,但它并不相同。帮助我,让我的开发人员更容易写后端。
答案 0 :(得分:3)
尝试使用
password_hash($字符串);
您可以使用
进行验证password_verify($字符串,$散列);
希望有所帮助!!
答案 1 :(得分:2)
我猜这是Illuminate\Hashing\BcryptHasher::make()
方法。您可以检查该类的来源,看看发生了什么:
<?php namespace Illuminate\Hashing;
class BcryptHasher implements HasherInterface {
protected $rounds = 10;
public function make($value, array $options = array())
{
$cost = isset($options['rounds']) ? $options['rounds'] : $this->rounds;
$hash = password_hash($value, PASSWORD_BCRYPT, array('cost' => $cost));
if ($hash === false)
{
throw new \RuntimeException("Bcrypt hashing not supported.");
}
return $hash;
}
因此,要在核心PHP中执行此操作,您需要执行以下操作:
$string = "some string that needs to be hashed";
$hash = password_hash($string, PASSWORD_BCRYPT, array('cost' => 10));