當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。