public static long tianlHash(String str) {
		long hash = 0;

		int iLength = str.length();
		if (iLength == 0) {
			return 0;
		}

		if (iLength <= 256) {
			hash = 16777216L * (iLength - 1);
		} else {
			hash = 4278190080L;
		}

		int i;

		char ucChar;

		if (iLength <= 96) {
			for (i = 1; i <= iLength; i++) {
				ucChar = str.charAt(i - 1);
				if (ucChar <= 'Z' && ucChar >= 'A') {
					ucChar = (char) (ucChar + 32);
				}
				hash += (3 * i * ucChar * ucChar + 5 * i * ucChar + 7 * i + 11 * ucChar) % 16777216;
			}
		} else {
			for (i = 1; i <= 96; i++) {
				ucChar = str.charAt(i + iLength - 96 - 1);
				if (ucChar <= 'Z' && ucChar >= 'A') {
					ucChar = (char) (ucChar + 32);
				}
				hash += (3 * i * ucChar * ucChar + 5 * i * ucChar + 7 * i + 11 * ucChar) % 16777216;
			}
		}
		if (hash < 0) {
			hash *= -1;
		}
		return hash;
	}
public static long tianlHash ( String str ) { long hash = 0 ; int iLength = str . length ( ) ; if ( iLength == 0 ) { return 0 ; } if ( iLength <= 256 ) { hash = 16777216L * ( iLength - 1 ) ; } else { hash = 4278190080L ; } int i ; char ucChar ; if ( iLength <= 96 ) { for ( i = 1 ; i <= iLength ; i ++ ) { ucChar = str . charAt ( i - 1 ) ; if ( ucChar <= 'Z' && ucChar >= 'A' ) { ucChar = ( char ) ( ucChar + 32 ) ; } hash += ( 3 * i * ucChar * ucChar + 5 * i * ucChar + 7 * i + 11 * ucChar ) % 16777216 ; } } else { for ( i = 1 ; i <= 96 ; i ++ ) { ucChar = str . charAt ( i + iLength - 96 - 1 ) ; if ( ucChar <= 'Z' && ucChar >= 'A' ) { ucChar = ( char ) ( ucChar + 32 ) ; } hash += ( 3 * i * ucChar * ucChar + 5 * i * ucChar + 7 * i + 11 * ucChar ) % 16777216 ; } } if ( hash < 0 ) { hash *= - 1 ; } return hash ; }
TianL Hash算法

@param str 字符串
@return Hash值