Java Hash String hash(String s)

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

Description

hash

License

Apache License

Declaration

public static long hash(String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static long hash(String s) {
        long l = 0L;
        for (int i = 0; i < s.length() && i < 12; i++) {
            char c = s.charAt(i);
            l *= 37L;//w w  w.  ja va 2  s  .c o  m
            if (c >= 'A' && c <= 'Z') {
                l += (1 + c) - 65;
            } else if (c >= 'a' && c <= 'z') {
                l += (1 + c) - 97;
            } else if (c >= '0' && c <= '9') {
                l += (27 + c) - 48;
            }
        }
        for (; l % 37L == 0L && l != 0L; l /= 37L) {
        }
        return l;
    }
}

Related

  1. hash(String arg)
  2. hash(String data)
  3. hash(String data)
  4. hash(String name)
  5. hash(String password)
  6. hash(String s)
  7. hash(String s, int start, int end)
  8. hash(String src)
  9. hash(String str, int max)