CRC { public static byte[] appendCRC(final byte[] bytes) { final int len = bytes.length; final byte[] outputBytes = new byte[len + 1]; System.arraycopy(bytes, 0, outputBytes, 0, len); outputBytes[len] = computeCRC(bytes); return outputBytes; }  static byte computeCRC(final byte[] data); static byte computeCRC(final byte[] data, final int length); static byte computeCRC(final byte[] data, final int start, final int length); static byte[] appendCRC(final byte[] bytes); static byte[] calculate16CCITT(final byte[] data);  }
@Test public void testAppendCRC() throws Exception { byte[] input = new byte[]{0x00, (byte) 0xFF, 0x00}; byte[] output = CRC.appendCRC(input); assertEquals(CRC.computeCRC(input), output[input.length]); }