1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| public static function getCheckSum($udid, $checks){
try {
$tablo=array("a","8","c","d","e","L","g","h","j","k","l","7","n","o","p","q","V","s","H","u","v","w","x","y","z","1","B","3","4","5","6","m","b","9","A","2","C","D","E","F","G","t","I","J","K","f","M","N","O","P","Q","R","S","T","U","r","W","X","Y","Z");
$partcheck = substr($checks,10, 255);
$ipartcheck = (float)($partcheck);
$valToRemove = 0;
for($k=0; $k< 15; ++$k) {
$charval = substr($udid,-($k+1) , 1);
for($c = 0; $c < sizeof($tablo); ++$c)
{
if ($tablo[$c]==$charval)
{
if ($k == 0)
$valToRemove += $c;
else
$valToRemove += $k* 10 * $c;
}
}
}
$ret = substr($checks,0,10).($ipartcheck - $valToRemove);
return $ret;
} catch (Exception $ex) {
throw new BusinessException("Error checksum", BusinessException::ERROR_CHECKSUM);
}
} |
Partager