CRC16

object CRC16

CRC-16 class is a helper that calculates different types of CRC. Catalogue of CRC-16 algorithms: http://reveng.sourceforge.net/crc-catalogue/16.htm

Testing is based on 'check' from the link above and https://www.lammertbies.nl/comm/info/crc-calculation.html.

Functions

Link copied to clipboard
fun ARC(data: ByteArray, offset: Int, length: Int): Int

Calculates CRC-16 ARC over given range of bytes from the block of data. It is using the 0x8005 polynomial and 0x0000 initial value.

Link copied to clipboard
fun AUG_CCITT(data: ByteArray, offset: Int, length: Int): Int

Calculates CRC AUG-CCITT over given range of bytes from the block of data. It is using the 0x1021 polynomial and 0x1D0F initial value.

Link copied to clipboard
fun CCITT_FALSE(data: ByteArray, offset: Int, length: Int): Int

Calculates CRC CCITT-FALSE over given range of bytes from the block of data. It is using the 0x1021 polynomial and 0xFFFF initial value.

Link copied to clipboard
fun CCITT_Kermit(data: ByteArray, offset: Int, length: Int): Int

Calculates CRC CCITT (Kermit) over given range of bytes from the block of data. It is using the 0x1021 polynomial and 0x0000 initial value.

Link copied to clipboard
fun CRC(poly: Int, init: Int, data: ByteArray, offset: Int, length: Int, refin: Boolean, refout: Boolean, xorout: Int): Int

Calculates the CRC over given range of bytes from the block of data with given polynomial and initial value. This method may also reverse input bytes and reverse output CRC.

Link copied to clipboard
fun MAXIM(data: ByteArray, offset: Int, length: Int): Int

Calculates CRC-16 MAXIM over given range of bytes from the block of data. It is using the 0x8005 polynomial and 0x0000 initial value and XORs output with 0xFFFF.

Link copied to clipboard
fun MCRF4XX(data: ByteArray, offset: Int, length: Int): Int

Calculates CRC MCRF4XX over given range of bytes from the block of data. It is using the 0x1021 polynomial and 0xFFFF initial value.