/**
  * (non-PHPdoc)
  * 
  * @see \Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::encodePassword()
  */
 public function encodePassword(Password $password)
 {
     $rounds = 60000;
     // incresed rounds for harder bruteforce
     $salt = "";
     if ($password->getId() != null && $password->getId() != "") {
         $salt = $this->getRandomeSalt(16 - strlen($password->getId()));
         $salt = $password->getId() . "=" . $salt;
     } else {
         $salt = 'main=' . $this->getRandomeSalt();
     }
     $hash = crypt($password->getPasswordPlain(), '$6$rounds=' . $rounds . '$' . $salt . '$');
     $password->setHash('{crypt}' . $hash);
     $password->setPasswordPlain(null);
 }
 /**
  * (non-PHPdoc)
  *
  * @see \Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface::encodePassword()
  */
 public static function encodePassword(Password $password)
 {
     $rounds = 60000;
     // incresed rounds for harder bruteforce
     $salt = "";
     if ($password->getId() != null && $password->getId() != "") {
         $salt = self::getRandomeSalt(16 - strlen($password->getId()));
         $salt = $password->getId() . ($password->isMasterPassword() ? '+' : '=') . $salt;
     } else {
         $salt = 'default=' . self::getRandomeSalt();
     }
     $hash = crypt($password->getPasswordPlain(), '$6$rounds=' . $rounds . '$' . $salt . '$');
     $password->setHash('{crypt}' . $hash);
     $password->setPasswordPlain(null);
     $password->setEncoder(CryptEncoder::class);
 }
Exemplo n.º 3
0
 /**
  *
  * @param Password $password
  * @return Service
  */
 public function removePassword(Password $password)
 {
     if (!isset($this->passwords[$password->getId()])) {
         return $this;
     }
     $this->getAttributes()->get('userpassword')->removeElement($this->passwords[$password->getId()]->getAttribute());
     unset($this->passwords[$password->getId()]);
     return $this;
 }