本文整理匯總了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);
}
示例2: testSetCost
public function testSetCost()
{
$this->bcrypt->setCost('16');
$this->assertEquals('16', $this->bcrypt->getCost());
}
示例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));
}
示例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;
}
示例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]));