本文整理汇总了PHP中Zend\Crypt\Password\Bcrypt::setSalt方法的典型用法代码示例。如果您正苦于以下问题:PHP Bcrypt::setSalt方法的具体用法?PHP Bcrypt::setSalt怎么用?PHP Bcrypt::setSalt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Crypt\Password\Bcrypt
的用法示例。
在下文中一共展示了Bcrypt::setSalt方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPasswordBcrypt
public function setPasswordBcrypt(Bcrypt $passwordBcrypt)
{
$passwordBcrypt->setSalt(self::BCRYPT_SALT);
$passwordBcrypt->setCost(self::BCRYPT_COST);
$this->passwordBcrypt = $passwordBcrypt;
return $this;
}
示例2: testBackwardCompatibility
public function testBackwardCompatibility()
{
$this->bcrypt->setSalt($this->salt);
$this->bcrypt->setBackwardCompatibility(true);
$password = $this->bcrypt->create($this->password);
$this->assertEquals('$2a$', substr($password, 0, 4));
$this->assertEquals(substr($password, 4), substr($this->bcryptPassword, 4));
}
示例3: encryptPassword
/**
* Encrypt Password
*
* Creates a Bcrypt password hash
*
* @return String
*/
public static function encryptPassword($password)
{
$bcrypt = new Bcrypt(array('cost' => 10));
$passwordSalt = $bcrypt->create($password);
$bcrypt->setSalt($passwordSalt);
$encryptedPassword = $bcrypt->create($password);
return array('password' => $encryptedPassword, 'password_salt' => $passwordSalt);
}
示例4: testPasswordWith8bitCharacter
public function testPasswordWith8bitCharacter()
{
$password = 'test' . chr(128);
$this->bcrypt->setSalt($this->salt);
if (version_compare(PHP_VERSION, '5.3.7') >= 0) {
$this->assertEquals('$2y$14$MTIzNDU2Nzg5MDEyMzQ1NexAbOIUHkG6Ra.TK9QxHOVUhDxOe4dkW', $this->bcrypt->create($password));
} else {
$this->setExpectedException('Zend\\Crypt\\Password\\Exception\\RuntimeException', 'The bcrypt implementation used by PHP can contains a security flaw ' . 'using password with 8-bit character. ' . 'We suggest to upgrade to PHP 5.3.7+ or use passwords with only 7-bit characters');
$output = $this->bcrypt->create($password);
}
}
示例5: checkPassword
/**
* Preveri geslo uporabnika (vnos hasha in primerja z vnosom v bazi)
*
* @param string $user
* @param string $passwordGiven
*/
public static function checkPassword($user, $passwordGiven)
{
$bcrypt = new Bcrypt();
$bcrypt->setSalt(5.129217031120145E+28);
$bcrypt->setCost(5);
$passwordGiven = $bcrypt->create($passwordGiven);
if ($user->getEnabled()) {
return $user->password === $passwordGiven ? true : false;
} else {
return false;
}
}
示例6: setPassword
/**
* @param mixed $password
*/
public function setPassword($password)
{
$salt = Rand::getBytes(32, true);
$salt = SaltedS2k::calc('sha256', $password, $salt, 100000);
$bcryp = new Bcrypt();
$bcryp->setSalt($salt);
$this->password = $bcryp->create($password);
}
示例7: create
public function create($password)
{
$bcrypt = new Bcrypt();
$bcrypt->setSalt($salt);
return $bcrypt->create($password);
}
示例8: setPassword
public function setPassword($password)
{
$this->expect($password !== '' && $password !== null, "Geslo ne sme biti prazno", 1000474);
if ($this->preveriGeslo($password)) {
$bcrypt = new Bcrypt();
$bcrypt->setSalt(5.129217031120145E+28);
//$$ rb potrebno še dopolniti, da se bo salt generiral dinamično
$bcrypt->setCost(5);
$this->password = $bcrypt->create($password);
}
return $this;
}
示例9: testCreateWithSalt
public function testCreateWithSalt()
{
$this->bcrypt->setSalt($this->salt);
$password = $this->bcrypt->create($this->password);
$this->assertEquals($password, $this->bcryptPassword);
}
示例10: encryptPassword
public function encryptPassword($senha)
{
$bcrypt = new Bcrypt();
$bcrypt->setSalt($this->getSalt());
return $bcrypt->create($senha);
}
示例11: encrypt
/**
* @param \User\Entity\Auth $auth
* @param $password
* @return string
*/
public static function encrypt(\User\Entity\Auth $auth, $password)
{
$bcrypt = new Bcrypt();
$bcrypt->setSalt($auth->getTokenSecret());
return $bcrypt->create($password);
}