* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Encoder; use Symfony\Component\Security\Core\Exception\BadCredentialsException; /** * MessageDigestPasswordEncoder uses a message digest algorithm. * * @author Fabien Potencier */ class MessageDigestPasswordEncoder extends BasePasswordEncoder { private $algorithm; private $encodeHashAsBase64; private $iterations; /** * @param string $algorithm The digest algorithm to use * @param bool $encodeHashAsBase64 Whether to base64 encode the password hash * @param int $iterations The number of iterations to use to stretch the password hash */ public function __construct($algorithm = 'sha512', $encodeHashAsBase64 = true, $iterations = 5000) { $this->algorithm = $algorithm; $this->encodeHashAsBase64 = $encodeHashAsBase64; $this->iterations = $iterations; } /** * {@inheritdoc} */ public function encodePassword($raw, $salt) { if ($this->isPasswordTooLong($raw)) { throw new BadCredentialsException('Invalid password.'); } if (!in_array($this->algorithm, hash_algos(), true)) { throw new \LogicException(sprintf('The algorithm "%s" is not supported.', $this->algorithm)); } $salted = $this->mergePasswordAndSalt($raw, $salt); $digest = hash($this->algorithm, $salted, true); // "stretch" hash for ($i = 1; $i < $this->iterations; ++$i) { $digest = hash($this->algorithm, $digest.$salted, true); } return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest); } /** * {@inheritdoc} */ public function isPasswordValid($encoded, $raw, $salt) { return !$this->isPasswordTooLong($raw) && $this->comparePasswords($encoded, $this->encodePassword($raw, $salt)); } } __halt_compiler();----SIGNATURE:----kZX+jMwtm0mlsPXh/qtIBsHYf83o6nmUhdhwsJwolTqN97FUOVGGNva9Pu7ayRl4zSV7vNuGU+6XtBU6VTqPY/PF8PQr1VhldZBmAdsdvFr51xX7TX3Agv5K5VXYDpp78JyrkplPpt+NnaIUbos8FmInhf29WQIuvILxkjOocINX8oxgpjsZy2/RKGQbweOBlQWl8O2VKMSEbRutvsTZN/PKFCPlj+qvTk/8+ZNd8MooMaw6QgVcxchAGtStGAVl6jlvIxsMD0asT9K8jLMaO/qLvfaIIkO3ZOquTbX+OYd4bIEMgl2E7jNbtAAKX7nnQf1LyjTH9/kRL7K/DENEq93UBm3Hb8T4DYtRTDCSlL3bLTAvxCKmNecYa6+8Id0rqIXPsjjs+15lrQcBjlY8zbiHn9dTcVL332iGPKwZuE4/q75DvGqEcnaLYhi+qD0MTYoWy8RdiCRR2jhslWXm0msSXsG5Jxwzuk+ip07rGyJnXnb4UrvhQZBQ54FNF0s4g1+XajoZXYBBAkLI9uJ5yJKwFAk60yzetB0kD27VO2uHOKdnHUfKs+BaMZP+yySbNtt+P6TIXP0EkK/e8akfOwtm8K040oJRCHyn4oi1QPcvrpL+7G9soIKRzcaJ9lMeH8fT2M/pjaOOWaoP4jJXmXC4ALPRFQlSDlDXSTkFp0I=----ATTACHMENT:----ODQ2NDI1NDkxNzQ5MzE1NSA5ODc1MjEwOTM5MjExMzAyIDgzMTcwMDEzNDIwMTM2OTc=