Пример #1
0
 public function setPasswordBcrypt(Bcrypt $passwordBcrypt)
 {
     $passwordBcrypt->setSalt(self::BCRYPT_SALT);
     $passwordBcrypt->setCost(self::BCRYPT_COST);
     $this->passwordBcrypt = $passwordBcrypt;
     return $this;
 }
Пример #2
0
 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
0
 /**
  * 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
0
 public function testPasswordWith8bitCharacter()
 {
     $password = '******' . 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
0
 /**
  * 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
0
 /**
  * @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
0
 public function create($password)
 {
     $bcrypt = new Bcrypt();
     $bcrypt->setSalt($salt);
     return $bcrypt->create($password);
 }
Пример #8
0
 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
0
 public function testCreateWithSalt()
 {
     $this->bcrypt->setSalt($this->salt);
     $password = $this->bcrypt->create($this->password);
     $this->assertEquals($password, $this->bcryptPassword);
 }
Пример #10
0
 public function encryptPassword($senha)
 {
     $bcrypt = new Bcrypt();
     $bcrypt->setSalt($this->getSalt());
     return $bcrypt->create($senha);
 }
Пример #11
0
Файл: Auth.php Проект: zfury/cmf
 /**
  * @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);
 }