List of utility methods to do Hash Code Calculate
String | getHashStringFromId(String id) Create Hash (string) value from id string by using SHA-256 hash algorithm Return null if id is null or functionality is not supported by JVM if (id == null) return null; try { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(id.getBytes("UTF-8")); byte[] digest = md.digest(); return bytesToHex(digest); } catch (NoSuchAlgorithmException e) { ... |
int | getHexDigit(String s, int i) get Hex Digit char c = s.charAt(i); if (c >= '0' && c <= '9') { return c - '0'; } else if (c >= 'a' && c <= 'f') { return c - 'a' + 0xa; } else if (c >= 'A' && c <= 'F') { return c - 'A' + 0xa; } else { ... |
int | createHash(String title, String URL, String content) create Hash int hash = 1; hash = hash * 31 + (title == null ? 0 : title.hashCode()); hash = hash * 31 + (URL == null ? 0 : URL.hashCode()); hash = hash * 31 + (content == null ? 0 : content.hashCode()); return hash; |
String | createHash(String toHash) create Hash String mResult = null; try { MessageDigest mDigest = MessageDigest .getInstance(HASH_ALGORITHM); mDigest.reset(); mDigest.update(toHash.getBytes()); byte[] mBytes = mDigest.digest(); int mLength = mBytes.length; ... |
int | hash(int aSeed, boolean aBoolean) Hash code for boolean primitives. return firstTerm(aSeed) + (aBoolean ? 1 : 0);
|
int | hash(int aSeed, char aChar) Hash code for char primitives. return firstTerm(aSeed) + aChar;
|
int | hash(int aSeed, int aInt) Hash code for int primitives. return firstTerm(aSeed) + aInt;
|
int | hash(int aSeed, long aLong) Hash code for long primitives. return firstTerm(aSeed) + (int) (aLong ^ (aLong >>> 32)); |
int | hash(int aSeed, float aFloat) Hash code for float primitives. return hash(aSeed, Float.floatToIntBits(aFloat));
|
int | hash(int aSeed, double aDouble) Hash code for double primitives. return hash(aSeed, Double.doubleToLongBits(aDouble));
|