Companion

object Companion

Functions

Link copied to clipboard
fun appendCRC(byteStream: IndexedFile.ByteArrayOutputStream)

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
fun validatedBytesFrom(bytes: ByteArray): ByteArrayInputStream

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.