Here you can find the source of hashString(String str)
public static double hashString(String str)
//package com.java2s; //License from project: Open Source License public class Main { private static final int HASH_STRING_CHARS = 3; private static final int HASH_STRING_BASE = 256; public static double hashString(String str) { if (str == null) return 0; // System.out.println("STRING FOR HASH: " + str); double hashStringVal = 0.0; if (str.length() >= 3) { char[] hashChars = new char[HASH_STRING_CHARS]; for (int i = 0; i < HASH_STRING_CHARS; i++) { hashChars[i] = str.charAt(i); // System.out.println(hashChars[i]); }/*from w w w.java 2 s . co m*/ for (int i = 0; i < HASH_STRING_CHARS; i++) { // System.out.println(hashChars[i] + " | " + // (double)((int)hashChars[i]) + " | " + // Math.pow((double)HASH_STRING_BASE, (double)i)); hashStringVal += (double) ((int) hashChars[i]) * Math.pow((double) HASH_STRING_BASE, (double) (HASH_STRING_CHARS - i)); } return hashStringVal; } else { char[] hashChars = new char[str.length()]; for (int i = 0; i < str.length(); i++) hashChars[i] = str.charAt(i); for (int i = 0; i < str.length(); i++) { // System.out.println(hashChars[i] + " | " + // (double)((int)hashChars[i]) + " | " + // Math.pow((double)HASH_STRING_BASE, (double)i)); hashStringVal += (double) ((int) hashChars[i]) * Math.pow((double) HASH_STRING_BASE, (double) (HASH_STRING_CHARS - i)); } return hashStringVal; } } }