Unit tests for Crypto package
This commit is contained in:
@@ -48,7 +48,7 @@ abstract class AbstractCrypt extends AbstractAlgorithm
|
||||
*/
|
||||
public function getPasswordHash($password)
|
||||
{
|
||||
return crypt($password, self::getSalt());
|
||||
return crypt($password, $this->getSalt());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,6 +59,12 @@ class CryptArgon2 extends AbstractAlgorithm
|
||||
$timeCost = PASSWORD_ARGON2_DEFAULT_TIME_COST,
|
||||
$threads = PASSWORD_ARGON2_DEFAULT_THREADS
|
||||
) {
|
||||
if (version_compare(PHP_VERSION, "7.2.0") === -1) {
|
||||
throw new \RuntimeException(
|
||||
"PASSWORD_ARGON2I requires PHP 7.2.0 or above."
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($localization);
|
||||
$this->memoryCost = $memoryCost;
|
||||
$this->timeCost = $timeCost;
|
||||
|
||||
@@ -45,12 +45,11 @@ class Joomla extends AbstractAlgorithm
|
||||
*/
|
||||
public function getPasswordHash($password)
|
||||
{
|
||||
return md5(
|
||||
$password . ":" . Utils::randomString(
|
||||
32,
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
)
|
||||
$salt = Utils::randomString(
|
||||
32, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
);
|
||||
|
||||
return md5($password . $salt) . ":" . $salt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ abstract class SSHA extends AbstractAlgorithm
|
||||
$saltedPassword = base64_decode(
|
||||
preg_replace("/" . $this->getPrefix() . "/i", "", $dbHash)
|
||||
);
|
||||
$salt = substr($saltedPassword, -(strlen($saltedPassword) - 32));
|
||||
$salt = substr($saltedPassword, -32);
|
||||
$hash = self::ssha($password, $salt);
|
||||
|
||||
return hash_equals($dbHash, $hash);
|
||||
|
||||
Reference in New Issue
Block a user