List of utility methods to do Hash Calculate
int | hash(byte[] bytes) hash int crc = 0xffffffff; for (byte b : bytes) { crc = (crc >>> 8) ^ table[(crc ^ b) & 0xff]; crc = crc ^ 0xffffffff; return crc; |
int | hash(byte[] bytes) hash int h = 0; for (byte b : bytes) { h += 7 * h + b; return h; |
int | hash(byte[] data) Generate a hash for a byte array using a 32-bit FNV-1a hash. if (data == null || data.length == 0) { return 0; long hash = 2166136261L; for (byte b : data) { hash ^= b; hash *= 16777619L; return (int) hash; |
long | hash(byte[] digest, int number) hash return (((long) (digest[3 + number * 4] & 0xFF) << 24) | ((long) (digest[2 + number * 4] & 0xFF) << 16) | ((long) (digest[1 + number * 4] & 0xFF) << 8) | (digest[0 + number * 4] & 0xFF)) & 0xFFFFFFFFL; |
int | hash(char[] str, int start, int length) hash int h = 0; int end = start + length; for (int curr = start; curr < end; ++curr) h += (h << 3) + str[curr]; return h; |
int | hash(double value) Returns an integer hash code representing the given double value. long bits = Double.doubleToLongBits(value); return (int) (bits ^ (bits >>> 32)); |
int | hash(final boolean value) Returns the hash code of the specified boolean primitive. return value ? 1231 : 1237;
|
int | hash(final int value) hash return (((((value >>> 16) * -2048144789) >>> 13) * -1028477387) >>> 16);
|
int | hash(final Object key, final Object value) Utility implementing Entry#hashCode() . return key.hashCode() ^ value.hashCode();
|
String | hash(final Object object) hash final int hash = object.hashCode(); return hash > 0 ? String.valueOf(hash) : "0" + Math.abs(hash); |