summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes M. Schmitt <schmittjoh@gmail.com>2010-10-23 11:48:26 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2010-10-24 10:57:06 +0200
commit6df1393216e1568f45eac7942c5230f45da3b6e3 (patch)
treeec97068b317980cc08bd3612d4b427d1f19d6ba2
parent8655de8c47585551e6599c9bd4fa349e863f6866 (diff)
downloadsymfony-security-6df1393216e1568f45eac7942c5230f45da3b6e3.zip
symfony-security-6df1393216e1568f45eac7942c5230f45da3b6e3.tar.gz
symfony-security-6df1393216e1568f45eac7942c5230f45da3b6e3.tar.bz2
applies base64 encoding directly to the binary data instead of their hexadecimal representation
-rw-r--r--Encoder/MessageDigestPasswordEncoder.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/Encoder/MessageDigestPasswordEncoder.php b/Encoder/MessageDigestPasswordEncoder.php
index 22303b6..f7e481f 100644
--- a/Encoder/MessageDigestPasswordEncoder.php
+++ b/Encoder/MessageDigestPasswordEncoder.php
@@ -26,7 +26,7 @@ class MessageDigestPasswordEncoder extends BasePasswordEncoder
*
* @param string $algorithm The digest algorithm to use
* @param Boolean $encodeHashAsBase64 Whether to base64 encode the password hash
- * @param integer $iterations The number of iterations to use to stretch the password
+ * @param integer $iterations The number of iterations to use to stretch the password hash
*/
public function __construct($algorithm = 'sha256', $encodeHashAsBase64 = false, $iterations = 1)
{
@@ -45,14 +45,14 @@ class MessageDigestPasswordEncoder extends BasePasswordEncoder
}
$salted = $this->mergePasswordAndSalt($raw, $salt);
- $digest = hash($this->algorithm, $salted);
+ $digest = hash($this->algorithm, $salted, true);
// "stretch" hash
for ($i = 1; $i < $this->iterations; $i++) {
- $digest = hash($this->algorithm, $digest);
+ $digest = hash($this->algorithm, $digest, true);
}
- return $this->encodeHashAsBase64 ? base64_encode($digest) : $digest;
+ return $this->encodeHashAsBase64 ? base64_encode($digest) : bin2hex($digest);
}
/**