mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[feature/passwords] Add method for obtaining the hash settings only
This is needed for combined hashing of passwords. PHPBB3-11610
This commit is contained in:
parent
dae4327cfc
commit
857b90057b
3 changed files with 38 additions and 0 deletions
|
@ -87,4 +87,22 @@ class phpbb_crypto_driver_bcrypt extends phpbb_crypto_driver_base
|
||||||
{
|
{
|
||||||
return $this->helper->hash_encode64($this->helper->get_random_salt(22), 22);
|
return $this->helper->hash_encode64($this->helper->get_random_salt(22), 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function get_settings_only($hash, $full = false)
|
||||||
|
{
|
||||||
|
if ($full)
|
||||||
|
{
|
||||||
|
$pos = stripos($hash, '$', 1) + 1;
|
||||||
|
$length = 22 + (strripos($hash, '$') + 1 - $pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pos = strripos($hash, '$') + 1;
|
||||||
|
$length = 22;
|
||||||
|
}
|
||||||
|
return substr($hash, $pos, $length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,19 @@ interface phpbb_crypto_driver_interface
|
||||||
/**
|
/**
|
||||||
* Check the password against the supplied hash
|
* Check the password against the supplied hash
|
||||||
*
|
*
|
||||||
|
* @param string $password The password to check
|
||||||
|
* @param string $hash The password hash to check against
|
||||||
* @return bool True if password is correct, else false
|
* @return bool True if password is correct, else false
|
||||||
*/
|
*/
|
||||||
public function check($password, $hash);
|
public function check($password, $hash);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get only the settings of the specified hash
|
||||||
|
*
|
||||||
|
* @param string $hash Password hash
|
||||||
|
* @param bool $full Return full settings or only settings
|
||||||
|
* related to the salt
|
||||||
|
* @return string String containing the hash settings
|
||||||
|
*/
|
||||||
|
public function get_settings_only($hash, $full = false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,4 +141,12 @@ class phpbb_crypto_driver_salted_md5 extends phpbb_crypto_driver_base
|
||||||
'full' => substr($hash, 0, 12),
|
'full' => substr($hash, 0, 12),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function get_settings_only($hash, $full = false)
|
||||||
|
{
|
||||||
|
return substr($hash, 3, 9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue