Support additional check-only algorithms in Password class

This commit is contained in:
Kijin Sung 2015-09-24 12:09:22 +09:00
parent 03bc1a45e3
commit fece1fbc18

View file

@ -162,6 +162,10 @@ class Password
return $this->strcmpConstantTime($hash_to_compare, $hash);
default:
if(in_array($algorithm, hash_algos()))
{
return $this->strcmpConstantTime(hash($algorithm, $password), $hash);
}
return false;
}
}
@ -185,6 +189,22 @@ class Password
{
return 'md5';
}
elseif(strlen($hash) === 40 && ctype_xdigit($hash))
{
return 'sha1';
}
elseif(strlen($hash) === 64 && ctype_xdigit($hash))
{
return 'sha256';
}
elseif(strlen($hash) === 96 && ctype_xdigit($hash))
{
return 'sha384';
}
elseif(strlen($hash) === 128 && ctype_xdigit($hash))
{
return 'sha512';
}
elseif(strlen($hash) === 16 && ctype_xdigit($hash))
{
return 'mysql_old_password';