List of utility methods to do Hash String
long | hashCode(String s) hash Code long returnValue = hashCode(s, 31); return returnValue; |
String | hashCode(String sIn) Return a hashcode as a positive Integer for a String. In contrast to .hashCode(), this function returns a positive Integer. if (sIn == null) { return null; return "" + Math.abs(sIn.hashCode()); |
int | hashCode(String str) Computes a hash code for a string. final char[] chars = str.toCharArray(); int h = 0; for (int i = 0; i < chars.length; i++) { h = 31 * h + chars[i]; return h; |
long | hashCode1(String str) hash Code long hash = 0; long x = 0; for (int i = 0; i < str.length(); i++) { hash = (hash << 4) + str.charAt(i); if ((x = hash & 0xF0000000L) != 0) { hash ^= (x >> 24); hash &= ~x; return (hash & 0x7FFFFFFF); |
long | hashCode2(String str) hash Code long h = 1125899906842597L; int len = str.length(); for (int i = 0; i < len; i++) { h = 31 * h + str.charAt(i); return h; |
long | hashCode64(String s) Generate a 64 bit hash code for the specified string long h = 0; if (s != null && s.length() > 0) { int off = 0; int len = s.length(); for (int i = 0; i < len; i++) { h = 31 * h + s.charAt(off++); return h; |
long | hashCode64(String s) 64-bit variant of String#hashCode() long h = 1125899906842597L; int len = s.length(); for (int i = 0; i < len; i++) { h = 31 * h + s.charAt(i); return h; |
int | hashCodeIgnoreCase(String a) hash Code Ignore Case if (a == null) return 0; return a.toLowerCase().hashCode(); |
int | hashCodeOfStringArray(String[] stringArray) hash Code Of String Array if (stringArray == null) { return 0; int hashCode = 17; for (int i = 0; i < stringArray.length; i++) { String value = stringArray[i]; hashCode = hashCode * 31 + (value == null ? 0 : value.hashCode()); return hashCode; |
String | hashCodeToString(byte[] hash) Converts the given bytes to a hex String. StringBuffer sb = new StringBuffer(""); for (int i = 0; i < hash.length; i++) sb.append(Integer.toString((hash[i] & 0xff) + 0x100, 16).substring(1)); return sb.toString(); |