本文整理汇总了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]));