-
Notifications
You must be signed in to change notification settings - Fork 11
/
pagerank.cpp
47 lines (35 loc) · 944 Bytes
/
pagerank.cpp
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
36
37
38
39
40
41
42
43
44
45
46
47
/*
pagerank.cpp
Google Pagerank Checksum Algorithm (Using the Firefox Toolbar)
Downloaded from http://pagerank.phurix.net/
Compile With:
gcc -Wall -O2 pagerank.cpp -o pagerank
Validating Environment:
Debian GNU/Linux Lenny(Kernel 2.6.25-7-686)
gcc version 4.3.1
*/
#include <stdio.h>
#include <string.h>
unsigned int HashURL(char* url)
{
char seed[] = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
unsigned int i, urllen, seedlen;
unsigned int key = 16909125;
seedlen = strlen(seed);
urllen = strlen(url);
for(i = 0; i < urllen; i++)
{
key ^= seed[i%seedlen] ^ url[i];
key = key>>23 | key<<9;
}
return key;
}
int main (int argc, char ** argv)
{
if(argc != 2) {
printf("Usage: %s [URL]\n",argv[0]);
return -1;
}
printf("Checksum=8%x\n", HashURL(argv[1]));
return 0;
}