Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function encode($subject, $salt)
 {
     if (empty($salt)) {
         return $subject;
     }
     try {
         return $this->merger->merge($subject, $salt);
     } catch (\DomainException $e) {
         throw new \DomainException($e->getMessage());
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function encode($subject, $salt)
 {
     if (!in_array($this->algorithm, hash_algos(), true)) {
         throw new \DomainException(sprintf('The algorithm "%s" is not supported.', $this->algorithm));
     }
     try {
         $salted = $this->merger->merge($subject, $salt);
     } catch (\DomainException $e) {
         throw new \DomainException($e->getMessage());
     }
     $digest = hash($this->algorithm, $salted, true);
     for ($i = 1; $i < $this->iterations; $i++) {
         $digest = hash($this->algorithm, sprintf("%s%s", $digest, $salted), true);
     }
     return $this->useBase64 ? base64_encode($digest) : bin2hex($digest);
 }