Java Utililty Methods Hash String

List of utility methods to do Hash String

Description

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

Method

StringhashCodeToString(long code)
hash Code To String
if (code < 0) {
    return "0" + (code * -1);
} else {
    return "" + code;
booleanhasHeirarchy(String xpath)
has Heirarchy
return xpath.contains("/");
booleanhasHexOrDecLongUrnSuffix(String value)
has Hex Or Dec Long Urn Suffix
String[] arr = value.split(":");
String suffix = arr[arr.length - 1];
return assertHexOrDecLongValue(suffix);
booleanhasHexPrefix(final String hexSymbols)
has Hex Prefix
return (hexSymbols.startsWith(HEX_STRING_PREFIX1) || hexSymbols.startsWith(HEX_STRING_PREFIX2));
booleanhasHighChars(String s)
has High Chars
int len = s.length();
for (int i = 0; i < len; i++) {
    char ch = s.charAt(i);
    if (ch < LOWCHAR || ch > HIGHCHAR) {
        if (ch != '\n' && ch != '\r')
            return true;
return false;
booleanhasHint(String hint, String parameter)
has Hint
return getHint(hint, parameter) != null;
inthashIt(String s)
hash It
int hash = 0;
int prime = 37;
for (int i = 0; i < s.length(); i++) {
    hash += hash * prime + s.charAt(i);
return hash;
booleanhasHost(String path)
Is a host present in the url
return path.startsWith("http://") || path.startsWith("https://");
StringhashOTP(String otp)
hash OTP
return Integer.toString(otp.hashCode());
shorthashPassword(String password)
hash Password
byte[] passwordCharacters = password.getBytes();
int hash = 0;
if (passwordCharacters.length > 0) {
    int charIndex = passwordCharacters.length;
    while (charIndex-- > 0) {
        hash = ((hash >> 14) & 0x01) | ((hash << 1) & 0x7fff);
        hash ^= passwordCharacters[charIndex];
    hash = ((hash >> 14) & 0x01) | ((hash << 1) & 0x7fff);
    hash ^= passwordCharacters.length;
    hash ^= (0x8000 | ('N' << 8) | 'K');
return (short) hash;