首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Laravel Hash等效于核心php

Laravel Hash等效于核心php
EN

Stack Overflow用户
提问于 2014-07-19 07:49:12
回答 2查看 2K关注 0票数 6

我已经有了一个web应用程序,在该应用程序中,我使用

Hash::make($string);

什么是相当于核心的php,这将帮助我的android开发人员同步我的应用程序。我试过用哈希和地窖,这不一样。帮助我编写后端,这样我的开发人员就更容易编写后端了。

EN

Stack Overflow用户

发布于 2014-07-19 07:58:27

我想这就是Illuminate\Hashing\BcryptHasher::make()方法。您可以检查该类的来源,以了解发生了什么:

代码语言:javascript
运行
复制
<?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中做到这一点,您需要执行如下操作:

代码语言:javascript
运行
复制
$string = "some string that needs to be hashed";
$hash = password_hash($string, PASSWORD_BCRYPT, array('cost' => 10));
票数 2
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24838039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档