mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Use a better algorithm to hash new passwords
SVN:trunk[5997]
This commit is contained in:
@@ -42,6 +42,7 @@ class ormPassword
|
||||
public function __construct($sHash = '', $sSalt = '')
|
||||
{
|
||||
$this->m_sHashed = $sHash;
|
||||
//only used for <= 2.5 hashed password
|
||||
$this->m_sSalt = $sSalt;
|
||||
}
|
||||
|
||||
@@ -50,8 +51,7 @@ class ormPassword
|
||||
*/
|
||||
public function SetPassword($sClearTextPassword)
|
||||
{
|
||||
$this->m_sSalt = SimpleCrypt::GetNewSalt();
|
||||
$this->m_sHashed = $this->ComputeHash($sClearTextPassword);
|
||||
$this->m_sHashed = password_hash($sClearTextPassword, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,10 +95,21 @@ class ormPassword
|
||||
public function CheckPassword($sClearTextPassword)
|
||||
{
|
||||
$bResult = false;
|
||||
$sHashedPwd = $this->ComputeHash($sClearTextPassword);
|
||||
if ($this->m_sHashed == $sHashedPwd)
|
||||
$aInfo = password_get_info($this->m_sHashed);
|
||||
switch ($aInfo["algoName"])
|
||||
{
|
||||
$bResult = true;
|
||||
case 'bcrypt':
|
||||
$bResult = password_verify($sClearTextPassword, $this->m_sHashed);
|
||||
break;
|
||||
case 'unknown':
|
||||
$sHashedPwd = $this->ComputeHash($sClearTextPassword);
|
||||
if ($this->m_sHashed == $sHashedPwd)
|
||||
{
|
||||
$bResult = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//shouldn't happen until php modify PASSWORD_DEFAULT
|
||||
}
|
||||
return $bResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user