Drupal 7 hash - fixes

This commit is contained in:
Marcin Łojewski
2018-10-03 21:44:02 +02:00
parent fa436280b7
commit 23ccb5d7b0
5 changed files with 94 additions and 39 deletions

View File

@@ -61,7 +61,7 @@ class Phpass extends AbstractAlgorithm
*
* @return string|null Generated hash. Null on invalid settings.
*/
private function crypt($password, $setting)
protected function crypt($password, $setting)
{
$countLog2 = strpos(self::ITOA64, $setting[3]);
if ($countLog2 < 7 || $countLog2 > 30) {
@@ -75,17 +75,29 @@ class Phpass extends AbstractAlgorithm
return null;
}
$hash = md5($salt . $password, true);
$hash = $this->hash($salt . $password);
do {
$hash = md5($hash . $password, true);
$hash = $this->hash($hash . $password);
} while (--$count);
$output = substr($setting, 0, 12);
$output .= $this->encode64($hash, 16);
$output .= $this->encode64($hash, strlen($hash));
return $output;
}
/**
* Apply hash function to input.
*
* @param string $input Input string.
*
* @return string Hashed input.
*/
protected function hash($input)
{
return md5($input, true);
}
/**
* Encode binary input to base64 string.
*