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

long[]hashPassword(String password)
Generate binary hash from raw text string Used for Pre-4.1 password handling

long nr = 1345345333L;
long add = 7;
long nr2 = 0x12345671L;
long tmp;
for (int i = 0; i < password.length(); ++i) {
    switch (password.charAt(i)) {
    case ' ':
    case '\t':
...
longhashSpriteName(String name)
hash Sprite Name
name = name.toUpperCase();
long hash = 0L;
for (int index = 0; index < name.length(); index++) {
    hash = (hash * 61L + (long) name.charAt(index)) - 32L;
    hash = hash + (hash >> 56) & 0xffffffffffffffL;
return hash;
longhashString(CharSequence str)
hash String
long hash = 0;
if (str == null)
    return hash;
for (int i = 0, l = str.length(); i < l; i++) {
    hash += str.charAt(i);
    hash += (hash << 10);
    hash ^= (hash >> 6);
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
hash = rehash(hash);
return hash;
inthashString(String data, int seed)
Murmur Hash 1.
int m = 0x5bd1e995;
int r = 24;
int length = data.length();
int h = seed ^ length;
int len_4 = length >> 2;
for (int i = 0; i < len_4; i++) {
    int i_4 = i << 2;
    int k = (byte) data.charAt(i_4 + 3);
...
inthashString(String s)
Calculate a hash code on a String a la Perl.
int hash = 1;
for (int i = 0; i < s.length(); i++) {
    hash *= 33 + s.charAt(i);
return hash;
inthashString(String s)
hash String
return s == null ? 0 : s.hashCode();
inthashString(String s)
hash String
int hashcode = s.hashCode();
for (char c : s.toCharArray()) {
    if (Character.isDigit(c)) {
        int digit = (int) c;
        hashcode += digit * (hashcode % 50);
return hashcode;
...
inthashString(String str)
hash String
int hash = 7;
for (int i = 0; i < str.length(); i++) {
    hash = hash * 31 + str.charAt(i);
return hash;
doublehashString(String str)
hash String
if (str == null)
    return 0;
double hashStringVal = 0.0;
if (str.length() >= 3) {
    char[] hashChars = new char[HASH_STRING_CHARS];
    for (int i = 0; i < HASH_STRING_CHARS; i++) {
        hashChars[i] = str.charAt(i);
    for (int i = 0; i < HASH_STRING_CHARS; i++) {
        hashStringVal += (double) ((int) hashChars[i])
                * Math.pow((double) HASH_STRING_BASE, (double) (HASH_STRING_CHARS - i));
    return hashStringVal;
} else {
    char[] hashChars = new char[str.length()];
    for (int i = 0; i < str.length(); i++)
        hashChars[i] = str.charAt(i);
    for (int i = 0; i < str.length(); i++) {
        hashStringVal += (double) ((int) hashChars[i])
                * Math.pow((double) HASH_STRING_BASE, (double) (HASH_STRING_CHARS - i));
    return hashStringVal;
StringhashTermToString(int i, int h)
hash Term To String
return Integer.toString(i) + DELIMITER + Integer.toString(h);