code: public static int hashBytes(byte[] bytes, int offset, int length) {
      int hash = 1;
      for (int i = offset; i < offset + length; i++) {
        hash = (31 * hash) + bytes[i];
      }
      return hash;
    }
docs: Compute hash for binary data.