Java Hash String hash(String src)

Here you can find the source of hash(String src)

Description

hash

License

Open Source License

Declaration

private static long[] hash(String src) 

Method Source Code

//package com.java2s;

public class Main {
    private static long[] hash(String src) {
        long nr = 1345345333L;
        long add = 7;
        long nr2 = 0x12345671L;
        long tmp;
        for (int i = 0; i < src.length(); ++i) {
            switch (src.charAt(i)) {
            case ' ':
            case '\t':
                continue;
            default:
                tmp = (0xff & src.charAt(i));
                nr ^= ((((nr & 63) + add) * tmp) + (nr << 8));
                nr2 += ((nr2 << 8) ^ nr);
                add += tmp;//  w w w . j  av a2s  .c  o m
            }
        }
        long[] result = new long[2];
        result[0] = nr & 0x7fffffffL;
        result[1] = nr2 & 0x7fffffffL;
        return result;
    }
}

Related

  1. hash(String name)
  2. hash(String password)
  3. hash(String s)
  4. hash(String s)
  5. hash(String s, int start, int end)
  6. hash(String str, int max)
  7. hash(String str, int offset)
  8. hash(String string)
  9. hash(String string, int length)