public function setPasswordBcrypt(Bcrypt $passwordBcrypt) { $passwordBcrypt->setSalt(self::BCRYPT_SALT); $passwordBcrypt->setCost(self::BCRYPT_COST); $this->passwordBcrypt = $passwordBcrypt; return $this; }
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)); }
/** * 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); }
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); } }
/** * 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; } }
/** * @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); }
public function create($password) { $bcrypt = new Bcrypt(); $bcrypt->setSalt($salt); return $bcrypt->create($password); }
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; }
public function testCreateWithSalt() { $this->bcrypt->setSalt($this->salt); $password = $this->bcrypt->create($this->password); $this->assertEquals($password, $this->bcryptPassword); }
public function encryptPassword($senha) { $bcrypt = new Bcrypt(); $bcrypt->setSalt($this->getSalt()); return $bcrypt->create($senha); }
/** * @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); }