import java.lang.Math; public class Hasher { public static long elf(String toHash) { long hashValue = 0; for (int Pos = 0; Pos < toHash.length(); Pos++) { // use all elements hashValue = (hashValue << 4) + toHash.charAt(Pos); // shift/mix long hiBits = hashValue & 0xF0000000; // get high nybble if (hiBits != 0) { hashValue ^= hiBits >> 24; // xor high nybble with second nybble } hashValue &= ~hiBits; // clear high nybble } return hashValue; } public static long sum(String toHash) { long hashValue = 0; for (int Pos = 0; Pos < toHash.length(); Pos++) { hashValue = hashValue + toHash.charAt(Pos); } return hashValue; } public static long sfold(String s) { int intLength = s.length() / 4; long hashValue = 0; for (int j = 0; j < intLength; j++) { char c[] = s.substring(j * 4, (j * 4) + 4).toCharArray(); long mult = 1; for (int k = 0; k < c.length; k++) { hashValue += c[k] * mult; mult *= 256; } } char c[] = s.substring(intLength * 4).toCharArray(); long mult = 1; for (int k = 0; k < c.length; k++) { hashValue += c[k] * mult; mult *= 256; } return hashValue; } public static long sbdm(String str) { long hashValue = 0; for(int i = 0; i < str.length(); i++) { hashValue = str.charAt(i) + (hashValue << 6) + (hashValue << 16) - hashValue; } return hashValue; } };