Class Crc16
java.lang.Object
org.apache.commons.codec.digest.Crc16
- All Implemented Interfaces:
Checksum
CRC-16 checksum implementations you can customize with a table and init value.
Since there are so many CRC-16 variants, we do not pick a default.
For example, to create a create a custom variant of CRC16-MODBUS with an init value of 0x0000, use:
Checksum crc16 = CRC16.builder().setTable(CRC16.getModbusTable()).setInit(0x0000).get();
- Since:
- 1.20.0
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Crc16arc()Creates a new CRC16-CCITT Checksum.static Crc16.Builderbuilder()Creates a new builder.static Crc16ccitt()Creates a new CRC16-CCITT Checksum.static Crc16dnp()Creates a new CRC16-DNP Checksum.static int[]Gets a copy of the CRC16-CCITT table.static int[]Gets a copy of the CRC16-CCITT table.static int[]Gets a copy of the CRC16-DNP table.static int[]Gets a copy of the CRC16-IBM-SDLC table.static int[]Gets a copy of the CRC16-MAXIM table.static int[]Gets a copy of the CRC16-MCRF4XX table.static int[]Gets a copy of the CRC16-MODBUS table.static int[]Gets a copy of the CRC16-NRSC-5 table.longgetValue()static Crc16ibmSdlc()Creates a new CRC16-IBM-SDLC Checksum.static Crc16maxim()Creates a new instance for CRC16-MAXIM Checksum.static Crc16mcrf4xx()Creates a new instance for CRC16-MCRF4XX Checksum.static Crc16modbus()Creates a new instance for CRC16-MODBUS Checksum.static Crc16nrsc5()Creates a new instance for CRC16-NRSC-5 Checksum.voidreset()toString()voidupdate(byte[] b, int off, int len) voidupdate(int b) static Crc16usb()Creates a new instance for CRC16-USB Checksum.
-
Method Details
-
arc
-
builder
Creates a new builder.Since there are so many CRC-16 variants, we do not pick a default.
- Returns:
- a new builder.
-
ccitt
-
dnp
-
getArcTable
Gets a copy of the CRC16-CCITT table.- Returns:
- a copy of the CCRC16-CITT table.
-
getCcittTable
Gets a copy of the CRC16-CCITT table.- Returns:
- a copy of the CCRC16-CITT table.
-
getDnpTable
Gets a copy of the CRC16-DNP table.- Returns:
- a copy of the CCRC16-DNP table.
-
getIbmSdlcTable
Gets a copy of the CRC16-IBM-SDLC table.- Returns:
- a copy of the CRC16-IBM-SDLC table.
-
getMaximTable
Gets a copy of the CRC16-MAXIM table.- Returns:
- a copy of the CRC16-MAXIM table.
-
getMcrf4xxTable
Gets a copy of the CRC16-MCRF4XX table.- Returns:
- a copy of the CRC16-MCRF4XX table.
-
getModbusTable
Gets a copy of the CRC16-MODBUS table.- Returns:
- a copy of the CRC16-MODBUS table.
-
getNrsc5Table
Gets a copy of the CRC16-NRSC-5 table.- Returns:
- a copy of the CRC16-NRSC-5 table.
-
ibmSdlc
-
maxim
-
mcrf4xx
-
modbus
Creates a new instance for CRC16-MODBUS Checksum.CRC-16 checksum implementation based on polynomial
x<sup>16</spu> + x^15 + x^2 + 1 (0x8005).- The init value is
0xFFFF. - The XorOut value is
0x0000.
Also known as:
- CRC-16/MODBUST
- MODBUST
- Returns:
- a new CRC16-MODBUS Checksum.
- The init value is
-
nrsc5
-
usb
-
getValue
-
reset
-
toString
-
update
-
update
-