Companion
Functions
Link copied to clipboard
Given a ByteArrayOutputStream, compute and append a 4-byte cyclic redundancy checksum. Write the Int in big-Endian order. The CRC is reasonably resilient to single-bit errors, and usually catches longer errors as well.
Link copied to clipboard
Given an array of bytes, check that the last four bytes, when treated as a Big Endian unsigned int, agree with the CRC32 checksum of the bytes excluding the last four. Fail if they disagree. Answer a ByteArrayInputStream on the bytes excluding the last four.