CrcUtil { public static String toSingleCrcString(final byte[] bytes) throws IOException { if (bytes.length != 4) { throw new IOException((String.format( "Unexpected byte[] length '%d' for single CRC. Contents: %s", bytes.length, Arrays.toString(bytes)))); } return String.format("0x%08x", readInt(bytes, 0)); } 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 testToSingleCrcStringBadLength() throws Exception { LambdaTestUtils.intercept( IOException.class, "length", () -> CrcUtil.toSingleCrcString(new byte[8])); }
@Test public void testToSingleCrcString() throws IOException { byte[] buf = CrcUtil.intToBytes(0xcafebeef); assertEquals( "0xcafebeef", CrcUtil.toSingleCrcString(buf)); }