当前位置: 首页>>代码示例>>PHP>>正文


PHP Bcrypt::getCost方法代码示例

本文整理汇总了PHP中Zend\Crypt\Password\Bcrypt::getCost方法的典型用法代码示例。如果您正苦于以下问题:PHP Bcrypt::getCost方法的具体用法?PHP Bcrypt::getCost怎么用?PHP Bcrypt::getCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Crypt\Password\Bcrypt的用法示例。


在下文中一共展示了Bcrypt::getCost方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateUserPasswordHash

 protected function updateUserPasswordHash(UserEntity $user, $password, Bcrypt $bcrypt)
 {
     $hash = explode('$', $user->getPassword());
     if ($hash[2] === $bcrypt->getCost()) {
         return;
     }
     $user = $this->getHydrator()->hydrate(compact('password'), $user);
     $this->getMapper()->update($user);
 }
开发者ID:rafajaques,项目名称:colloquium,代码行数:9,代码来源:Db.php

示例2: testSetCost

 public function testSetCost()
 {
     $this->bcrypt->setCost('16');
     $this->assertEquals('16', $this->bcrypt->getCost());
 }
开发者ID:,项目名称:,代码行数:5,代码来源:

示例3: resetPassword

 public function resetPassword(array $credentials)
 {
     $username = $credentials['username'];
     $password = $credentials['password'];
     $em = $this->getEntityManager()->getRepository($this);
     $bcrypt = new Bcrypt();
     $bcrypt->setCost(14);
     $hash = explode('$', $userObject->getPassword());
     if ($hash[2] === $bcrypt->getCost()) {
         return;
     }
     $userObject->setPassword($bcrypt->create($password));
 }
开发者ID:neuweb,项目名称:idauth,代码行数:13,代码来源:Doctrine.php

示例4: updateUserPasswordHash

 /**
  * @param UserEntity $userObject
  * @param $password
  * @param Bcrypt $bcrypt
  * @return $this|bool
  */
 protected function updateUserPasswordHash(UserEntity $userObject, $password, Bcrypt $bcrypt)
 {
     $hash = explode('$', $userObject->getPassword());
     if ($hash[2] === $bcrypt->getCost()) {
         return true;
     }
     $userObject->setPassword($bcrypt->create($password));
     $this->getUserMapper()->update($userObject);
     return $this;
 }
开发者ID:bedi,项目名称:mfcc-admin-module,代码行数:16,代码来源:Db.php

示例5: realpath

 * @copyright Copyright (c) 2014-2016 Zend Technologies USA Inc. (http://www.zend.com)
 */
use Zend\Crypt\Password\Bcrypt;
$autoload = realpath(__DIR__ . '/../vendor/autoload.php');
if (!$autoload) {
    // Attempt to locate it relative to the application root
    $autoload = realpath(__DIR__ . '/../../../autoload.php');
}
if (!$autoload) {
    throw new RuntimeException('Unable to locate autoloader. Please run `composer install`.');
}
include $autoload;
$help = <<<EOH
Usage:
  php bcrypt.php <password> [cost]

Arguments:
  <password>      The user's password
  [cost]          The value of the cost parameter of bcrypt.
                  (default is %d)

EOH;
$bcrypt = new Bcrypt();
if ($argc < 2) {
    printf($help, $bcrypt->getCost());
    exit(1);
}
if (isset($argv[2])) {
    $bcrypt->setCost($argv[2]);
}
printf("%s\n", $bcrypt->create($argv[1]));
开发者ID:zfcampus,项目名称:zf-oauth2,代码行数:31,代码来源:bcrypt.php


注:本文中的Zend\Crypt\Password\Bcrypt::getCost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。