All pastes #589166 Raw Edit

Miscellany

public text v1 · immutable
#589166 ·published 2007-06-25 21:12 UTC
rendered paste body
g.getHash = function(value) {
  var combination = 16909125;
  var seed = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
  var doIcare = 'no';
  for(var i = 0; i < value.length; i++ ) {
    combination ^= seed.charCodeAt(i % seed.length) ^ value.charCodeAt(i);
    combination = combination >>> 23 | combination << 9;
  }
  return this.hexEncodeU32(combination);
}
g.hexEncodeU32 = function(num) {
  var result = this.toHex8(num >>> 24);
  result += this.toHex8(num >>> 16 & 255);
  result += this.toHex8(num >>> 8 & 255);
  return result + this.toHex8(num & 255);
}
g.toHex8 = function(num) {
  return(num < 16 ? "0" : "") + num.toString(16);
}