well it's used for protecting my highscore list.
My flash program creates a checksum for the score.
And then the php should create a checksum and see if it matches the flash checksum.
Code looks like this
[PHP]$score = "21700";
$scorepre = $score*2;
echo $scorepre . "<br>";
for($c=0;$c<strlen($scorepre);$c++) {
@$realscorecheck+=$scorepre{$c}*($c+1);
@$realscorecheck-="1";
}
echo $realscorecheck;PHP] ///-5
PHP Code:
$score = "43400";
$scorepre = $score;
echo $scorepre . "<br>";
for($c=0;$c<strlen($scorepre);$c++) {
@$realscorecheck+=$scorepre{$c}*($c+1);
@$realscorecheck-="1";
}
echo $realscorecheck;
///17
What i want to do is take each character in $scorepre and multiply the first one with 1 the second character with 2 the third one with 3 and so on. Then take 1 of per character.
And then ad all those results together.
Example:
43400 gives
(4*1-1)+(3*2-1)+(4*3-1)+(0*4-1)+(0*5-1)
3+5+11-1-1=17
The problem is i need to get the score and multiply it before doing above.
And for some reason 43400 gives the right number (17)
And 2*21700 gives -5
Last edited by lajkonik86; 09-29-2004 at 09:32 AM..
|