Modified Hash Function

This is the hash function in JAVA. I was able to convert the c++ version
to JAVA. The tested result was identical to the c++ version so it should
be correct. -Kevin Lai