-
public final class CRC16CRC-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.
-
-
Method Summary
Modifier and Type Method Description static intCCITT_Kermit(@NonNull() Array<byte> data, int offset, int length)Calculates CRC CCITT (Kermit) over given range of bytes from the block of data.It is using the 0x1021 polynomial and 0x0000 initial value. static intCCITT_FALSE(@NonNull() Array<byte> data, int offset, int length)Calculates CRC CCITT-FALSE over given range of bytes from the block of data.It is using the 0x1021 polynomial and 0xFFFF initial value. static intMCRF4XX(@NonNull() Array<byte> data, int offset, int length)Calculates CRC MCRF4XX over given range of bytes from the block of data.It is using the 0x1021 polynomial and 0xFFFF initial value. static intAUG_CCITT(@NonNull() Array<byte> data, int offset, int length)Calculates CRC AUG-CCITT over given range of bytes from the block of data.It is using the 0x1021 polynomial and 0x1D0F initial value. static intARC(@NonNull() Array<byte> data, int offset, int length)Calculates CRC-16 ARC over given range of bytes from the block of data.It is using the 0x8005 polynomial and 0x0000 initial value. static intMAXIM(@NonNull() Array<byte> data, int offset, int length)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. static intCRC(int poly, int init, @NonNull() Array<byte> data, int offset, int length, boolean refin, boolean refout, int xorout)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. -
-
Method Detail
-
CCITT_Kermit
static int CCITT_Kermit(@NonNull() Array<byte> data, int offset, int length)
Calculates CRC CCITT (Kermit) over given range of bytes from the block of data.It is using the 0x1021 polynomial and 0x0000 initial value.
See: crc.cat.kermit
- Parameters:
data- The input data block for computation.offset- Offset from where the range starts.length- Length of the range in bytes.
-
CCITT_FALSE
static int CCITT_FALSE(@NonNull() Array<byte> data, int offset, int length)
Calculates CRC CCITT-FALSE over given range of bytes from the block of data.It is using the 0x1021 polynomial and 0xFFFF initial value.
See: crc-16-ccitt-falseSee: crc16-ccitt
- Parameters:
data- The input data block for computation.offset- Offset from where the range starts.length- Length of the range in bytes.
-
MCRF4XX
static int MCRF4XX(@NonNull() Array<byte> data, int offset, int length)
Calculates CRC MCRF4XX over given range of bytes from the block of data.It is using the 0x1021 polynomial and 0xFFFF initial value.
This method is used in Bluetooth LE CGMS service E2E-CRC calculation.
See: crc.cat.crc-16-mcrf4xxSee: Bluetooth Specifications -> CGMS (1.0.1)
- Parameters:
data- The input data block for computation.offset- Offset from where the range starts.length- Length of the range in bytes.
-
AUG_CCITT
static int AUG_CCITT(@NonNull() Array<byte> data, int offset, int length)
Calculates CRC AUG-CCITT over given range of bytes from the block of data.It is using the 0x1021 polynomial and 0x1D0F initial value.
See: crc-16-aug-ccittSee: crc16-ccitt
- Parameters:
data- The input data block for computation.offset- Offset from where the range starts.length- Length of the range in bytes.
-
ARC
static int ARC(@NonNull() Array<byte> data, int offset, int length)
Calculates CRC-16 ARC over given range of bytes from the block of data.It is using the 0x8005 polynomial and 0x0000 initial value.
Input data and output CRC are reversed.
See: crc-16-arc
- Parameters:
data- The input data block for computation.offset- Offset from where the range starts.length- Length of the range in bytes.
-
MAXIM
static int MAXIM(@NonNull() Array<byte> data, int offset, int length)
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.
Input data and output CRC are reversed.
See: crc-16-maxim
- Parameters:
data- The input data block for computation.offset- Offset from where the range starts.length- Length of the range in bytes.
-
CRC
static int CRC(int poly, int init, @NonNull() Array<byte> data, int offset, int length, boolean refin, boolean refout, int xorout)
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.
See: CRC Calculator
- Parameters:
poly- Polynomial used to calculate the CRC16.init- Initial value to feed the buffer.data- The input data block for computation.offset- Offset from where the range starts.length- Length of the range in bytes.refin- True if the input data should be reversed.refout- True if the output data should be reversed.
-
-
-
-