Fonction Google CheckSum

Voter Contre Cet ArticleVoter Pour Cet Article (+29 rating, 7 votes)
Loading ... Loading ...
Ajouter sur The-News

Une des fonctions les plus utilisées par google, le calcul du checksum !!!

Beaucoup de developpeurs utilisent ce calcul du checksum pour offrir aux visiteurs de leur sites un service d’affichage du page-rank, il est possible d’utiliser les API de google pour ça mais comme google limite les requetes Ă  1000 par jour, la fonction, ci-dessous, resolve ce problĂ©me de limitation.

GoogleCSum($s,$key){
$v4=$len=strlen($s); $esi=$key; $ebx=$edi=0×9E3779B9; $p=0;
if ($len>=12)
for($i=0;$i<floor($len/12);$i++)
{ $edi=unsign($edi+ord($s[$p+4])+(ord($s[$p+5]) << 8)+(ord($s[$p+6]) << 16)+(ord($s[$p+7]) << 24));
$esi=unsign($esi+ord($s[$p+8])+(ord($s[$p+9]) << 8)+(ord($s[$p+10]) << 16)+(ord($s[$p+11]) << 24));
$edx=unsign(($ebx+ord($s[$p+0])+(ord($s[$p+1]) << 8)+(ord($s[$p+2]) << 16)+(ord($s[$p+3]) << 24)-$edi-$esi)^shr($esi,13));
$edi=unsign(($edi-$esi-$edx)^($edx << 8));
$esi=unsign(($esi-$edx-$edi)^shr($edi,13));
$edx=unsign(($edx-$edi-$esi)^shr($esi,12));
$edi=unsign(($edi-$esi-$edx)^($edx << 16));
$esi=unsign(($esi-$edx-$edi)^shr($edi,5));
$edx=unsign(($edx-$edi-$esi)^shr($esi,3)); $ebx=$edx;
$edi=unsign(($edi-$esi-$ebx)^($ebx << 10));
$esi=unsign(($esi-$ebx-$edi)^shr($edi,15));
$v4-=12; $p+=12; }
$esi=unsign($esi+$len);
if ($v4>=11) $esi=unsign($esi+(ord($s[$p+10]) << 24));
if ($v4>=10) $esi=unsign($esi+(ord($s[$p+9]) << 16));
if ($v4>=9) $esi=unsign($esi+(ord($s[$p+8]) << 8));
if ($v4>=8) $edi=unsign($edi+ord($s[$p+4])+(ord($s[$p+5]) << 8)+(ord($s[$p+6]) << 16)+(ord($s[$p+7]) << 24));
else
{ if ($v4>=7) $edi=unsign($edi+(ord($s[$p+6]) << 16));
if ($v4>=6) $edi=unsign($edi+(ord($s[$p+5]) << 8));
if ($v4>=5) $edi=unsign($edi+ord($s[$p+4])); }
if ($v4>=4) $ebx=unsign($ebx+ord($s[$p+0])+(ord($s[$p+1]) << 8)+(ord($s[$p+2]) << 16)+(ord($s[$p+3]) << 24));
else
{ if ($v4>=3) $ebx=unsign($ebx+(ord($s[$p+2]) << 16));
if ($v4>=2) $ebx=unsign($ebx+(ord($s[$p+1]) << 8));
if ($v4>=1) $ebx=unsign($ebx+ord($s[$p+0])); }
$ebx=unsign(($ebx-$edi-$esi)^shr($esi,13));
$edi=unsign(($edi-$esi-$ebx)^($ebx << 8));
$esi=unsign(($esi-$ebx-$edi)^shr($edi,13));
$ebx=unsign(($ebx-$edi-$esi)^shr($esi,12));
$edi=unsign(($edi-$esi-$ebx)^($ebx << 16));
$esi=unsign(($esi-$ebx-$edi)^shr($edi,5));
$ebx=unsign(($ebx-$edi-$esi)^shr($esi,3));
$edi=unsign(($edi-$esi-$ebx)^($ebx << 10));
$esi=unsign(($esi-$ebx-$edi)^shr($edi,15)); return $esi;
}

Recommander cet article Recommander cet article

Laisser un commentaire

Subscribe without commenting