Small fixes

This commit is contained in:
RainLoop Team 2015-07-23 21:57:46 +04:00
parent fc10f20770
commit 3849fd02b4
9 changed files with 113 additions and 29 deletions

View file

@ -2448,6 +2448,38 @@ END;
return ('' === $sUser ? '' : $sUser.'@').$sDomain;
}
/**
* @param string $sHash
* @param string $sSalt
*
* @return int
*/
public static function HashToId($sHash, $sSalt = '')
{
$sData = $sHash ? @\MailSo\Base\Crypt::XxteaDecrypt(\hex2bin($sHash), \md5($sSalt)) : null;
$aMatch = array();
if ($sData && preg_match('/^id:(\d+)$/', $sData, $aMatch) && isset($aMatch[1]))
{
return is_numeric($aMatch[1]) ? (int) $aMatch[1] : null;
}
return null;
}
/**
* @param int $iID
* @param string $sSalt
*
* @return string
*/
public static function IdToHash($iID, $sSalt = '')
{
return is_int($iID) ?
\bin2hex(\MailSo\Base\Crypt::XxteaEncrypt('id:'.$iID, \md5($sSalt))) : null
;
}
/**
* @param string $sPassword
*