Pagerank Checksum in Java

October 11th, 2006

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.

[java]

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&255))+toHex8(key&255);

}
}[/java]

del.icio.us Digg Furl Reddit Ma.gnolia RawSugar Shadows Spurl StumbleUpon Tailrank Technorati

Tags: Java

RSS feed | Trackback URI

7 Comments »

Comment by George
2006-10-11 23:42:34

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

 
Comment by Ian
2006-11-23 00:47:59

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

 
Comment by admin
2006-11-23 10:01:19

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  

 
Comment by vinod
2006-11-27 10:35:27

this is suitable and esiest program avialable here.

 
Comment by metal
2007-04-24 05:07:13

thanks ,great work

 
Comment by Kris
2010-01-27 18:16:25

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

Comment by admin
2010-03-22 11:54:40

I wrote the code a long long time ago. So it very possible that a google update has broken it.

 
 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line=""> in your comment.

Article Categories

Recent Articles

Recommended

Feeds