Here you can find the source of hashByteArray(byte[] array, int startInclusive, int endExclusive)
Parameter | Description |
---|---|
array | a parameter |
startInclusive | a parameter |
endExclusive | a parameter |
public static byte hashByteArray(byte[] array, int startInclusive, int endExclusive)
//package com.java2s; public class Main { /**//w w w.j a v a 2s . c om * A utility to allow hashing of a portion of an array without having to copy it. * @param array * @param startInclusive * @param endExclusive * @return hash byte */ public static byte hashByteArray(byte[] array, int startInclusive, int endExclusive) { if (array == null) { return 0; } int range = endExclusive - startInclusive; if (range < 0) { throw new IllegalArgumentException(startInclusive + " > " + endExclusive); } int result = 1; for (int i = startInclusive; i < endExclusive; i++) { result = 31 * result + array[i]; } return (byte) result; } }