Pagerank Checksum in Java

A quick java class to calculate a web pages Page Rank Checksum. It can be used to obtian the Google Page Rank for a given url.The code is reverse engineered from the javascript used to build the Firefox page rank plugin. It calculates a checksum using a encoding algorithm.

public class Pagerank
{
private String toHex8(int num)
{
if(num<16) return "0"+Integer.toHexString(num);
else return Integer.toHexString(num);
}
public String calculateChecksum(String url)
{
String stupidGoogleHash = "Mining PageRank is AGAINST GOOGLE’S TERMS OF SERVICE. Yes, I’m talking to you, scammer.";
int key = 16909125;
for(int i=0; i < url.length(); i++) {
key = key ^ (int)(stupidGoogleHash.charAt(i%stupidGoogleHash.length()))^(int)(url.charAt(i));
key = key>>>23|key<<9;
}return "8"+toHex8(key>>>(8&#038;255))+toHex8(key&#038;255);
}
}

7 Responses to Pagerank Checksum in Java

  1. Thank you for the great example. It worked like a charm. Time for me to really learn some java now!

  2. I’d love to see an updated function in PHP that calculates the PageRank checksum. Any ideas? … meanwhile, googling.. ;)

  3. I have one for PHP as well, let me see if i can dig it up

    EDIT:

    okay you can find the php version here  

  4. this is suitable and esiest program avialable here.

  5. Has there been an update to the google toolbar or something?
    I can’t get it to work…. seems to be wrong checksum

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Go back to top