Java Hash Calculate hash(byte[] bytes)

Here you can find the source of hash(byte[] bytes)

Description

hash

License

BSD License

Declaration

public static int hash(byte[] bytes) 

Method Source Code

//package com.java2s;
// BSD License (http://lemurproject.org/galago-license)

public class Main {
    public static int hash(byte b) {
        return ((int) b) & 0xFF;
    }/*  w  w  w  .  j av a  2s. c  o  m*/

    public static int hash(int i) {
        return i;
    }

    public static int hash(long l) {
        return (int) l;
    }

    public static int hash(double d) {
        return (int) (d * 100000);
    }

    public static int hash(float f) {
        return (int) (f * 100000);
    }

    public static int hash(String s) {
        return s.hashCode();
    }

    public static int hash(byte[] bytes) {
        int h = 0;
        for (byte b : bytes) {
            h += 7 * h + b;
        }
        return h;
    }
}

Related

  1. hash(Boolean value)
  2. hash(boolean value, int seed)
  3. hash(boolean[] array)
  4. hash(byte x)
  5. hash(byte[] bytes)
  6. hash(byte[] data)
  7. hash(byte[] digest, int number)
  8. hash(char[] str, int start, int length)
  9. hash(double value)