Java Utililty Methods Hash Calculate

List of utility methods to do Hash Calculate

Description

The list of methods to do Hash Calculate are organized into topic(s).

Method

inthash(byte[] bytes)
hash
int crc = 0xffffffff;
for (byte b : bytes) {
    crc = (crc >>> 8) ^ table[(crc ^ b) & 0xff];
crc = crc ^ 0xffffffff;
return crc;
inthash(byte[] bytes)
hash
int h = 0;
for (byte b : bytes) {
    h += 7 * h + b;
return h;
inthash(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;
longhash(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;
inthash(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;
inthash(double value)
Returns an integer hash code representing the given double value.
long bits = Double.doubleToLongBits(value);
return (int) (bits ^ (bits >>> 32));
inthash(final boolean value)
Returns the hash code of the specified boolean primitive.
return value ? 1231 : 1237;
inthash(final int value)
hash
return (((((value >>> 16) * -2048144789) >>> 13) * -1028477387) >>> 16);
inthash(final Object key, final Object value)
Utility implementing Entry#hashCode() .
return key.hashCode() ^ value.hashCode();
Stringhash(final Object object)
hash
final int hash = object.hashCode();
return hash > 0 ? String.valueOf(hash) : "0" + Math.abs(hash);