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


PHP Bcrypt::setSalt方法代码示例

本文整理汇总了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;
 }
开发者ID:dulumao,项目名称:big5,代码行数:7,代码来源:InsertService.php

示例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));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:8,代码来源:BcryptTest.php

示例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);
 }
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:15,代码来源:UserService.php

示例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);
     }
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:11,代码来源:BcryptTest.php

示例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;
     }
 }
开发者ID:ifigenija,项目名称:server,代码行数:18,代码来源:AaaService.php

示例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);
 }
开发者ID:GlitchedMan,项目名称:armasquads,代码行数:11,代码来源:Benutzer.php

示例7: create

 public function create($password)
 {
     $bcrypt = new Bcrypt();
     $bcrypt->setSalt($salt);
     return $bcrypt->create($password);
 }
开发者ID:longhaily,项目名称:MariaTrinhVuong,代码行数:6,代码来源:UserPassword.php

示例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;
 }
开发者ID:ifigenija,项目名称:server,代码行数:12,代码来源:User.php

示例9: testCreateWithSalt

 public function testCreateWithSalt()
 {
     $this->bcrypt->setSalt($this->salt);
     $password = $this->bcrypt->create($this->password);
     $this->assertEquals($password, $this->bcryptPassword);
 }
开发者ID:,项目名称:,代码行数:6,代码来源:

示例10: encryptPassword

 public function encryptPassword($senha)
 {
     $bcrypt = new Bcrypt();
     $bcrypt->setSalt($this->getSalt());
     return $bcrypt->create($senha);
 }
开发者ID:ericoautocad,项目名称:module-security-zf2,代码行数:6,代码来源:Usuario.php

示例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);
 }
开发者ID:zfury,项目名称:cmf,代码行数:11,代码来源:Auth.php


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