Android Utililty Methods Hash Code Calculate

List of utility methods to do Hash Code Calculate

Description

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

Method

inthashCode(int x, int y, int z, int w)
hash Code
return hashCode(new int[] { x, y, z, w });
inthashCode(int x, int y, int z, int w, int t)
hash Code
return hashCode(new int[] { x, y, z, w, t });
inthashCode(int[] array)
Hash every element uniformly using the Modified Bernstein hash.
if (array == null) {
    return 0;
int h = 1;
for (int x : array) {
    h = ((h << 5) - h) ^ x; 
return h;
...
StringhashLocationMessage(String phone, double latitude, double longitude, long time)
generate a hash of a location message
String mToHash = phone + Double.toString(latitude)
        + Double.toString(longitude) + Long.toString(time);
return createHash(mToHash);
StringhashPointOfInterestMessage(String phone, double latitude, double longitude, String title, String description)
generate a hash of a point of interest message
String mToHash = phone + Double.toString(latitude)
        + Double.toString(longitude) + title + description;
return createHash(mToHash);
StringcomputeWeakHash(String string)
compute Weak Hash
return String.format(Locale.CHINA, "%08x%08x", string.hashCode(),
        string.length());
StringcomputeWeakHash(String string)
compute Weak Hash
return String.format(Locale.US, "%08x%08x", string.hashCode(),
        string.length());
StringgetHash(String text)
get Hash
try {
    return SHA1(text);
} catch (NoSuchAlgorithmException e) {
    Log.e(LOGTAG, "NoSuchAlgorithmException: " + e.toString(), e);
    return null; 
intgetHashCode(final Object... pObjects)
get Hash Code
final int prime = 31;
int result = 1;
for (int i = 0; i < pObjects.length; i++) {
    final Object object = pObjects[i];
    result = prime * result
            + ((object == null) ? 0 : object.hashCode());
return result;
...
intgetHashCode(final byte... pBytes)
get Hash Code
final int prime = 31;
int result = 1;
for (int i = 0; i < pBytes.length; i++) {
    result = prime * result + pBytes[i];
return result;