CrcUtil { public static String toMultiCrcString(final byte[] bytes) throws IOException { if (bytes.length % 4 != 0) { throw new IOException((String.format( "Unexpected byte[] length '%d' not divisible by 4. Contents: %s", bytes.length, Arrays.toString(bytes)))); } StringBuilder sb = new StringBuilder(); sb.append('['); for (int i = 0; i < bytes.length; i += 4) { sb.append(String.format("0x%08x", readInt(bytes, i))); if (i != bytes.length - 4) { sb.append(", "); } } sb.append(']'); return sb.toString(); } private  CrcUtil(); static int getMonomial(long lengthBytes, int mod); static int composeWithMonomial(
      int crcA, int crcB, int monomial, int mod); static int compose(int crcA, int crcB, long lengthB, int mod); static byte[] intToBytes(int value); static void writeInt(byte[] buf, int offset, int value); static int readInt(byte[] buf, int offset); static String toSingleCrcString(final byte[] bytes); static String toMultiCrcString(final byte[] bytes); static final int MULTIPLICATIVE_IDENTITY; static final int GZIP_POLYNOMIAL; static final int CASTAGNOLI_POLYNOMIAL; }
@Test public void testToMultiCrcStringBadLength() throws Exception { LambdaTestUtils.intercept( IOException.class, "length", () -> CrcUtil.toMultiCrcString(new byte[6])); }
@Test public void testToMultiCrcStringNoElements() throws IOException { assertEquals( "[]", CrcUtil.toMultiCrcString(new byte[0])); }