I’ve found this code on the web, can’t remember the exact source but the same code is on various sites.
private function pageRankUrl($q) {
$host='toolbarqueries.google.com';
$seed = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
$result = 0x01020345;
$len = strlen($q);
for ($i=0; $i<$len; $i++) {
$result ^= ord($seed{$i%strlen($seed)}) ^ ord($q{$i});
$result = (($result >> 23) & 0x1ff) | $result << 9;
}
$ch=sprintf('8%x', $result);
$url='http://%s/tbr?client=navclient-auto&ch=%s&features=Rank&q=info:%s';
$url=sprintf($url,$host,$ch,$q);
return $url;
}
The code works fine, but I just want help understanding it. I need to understand what the $seed is, and also what’s happening in the for loop.
It looks to me like the $seed and the for-loop reduce the query-string, i.e. compute a shorter version. This can be used for a hash-key or something. It looks to me like a reduction function from a rainbow-table when it’s compute a password-hash chain.