# Class Crc16

java.lang.Object
org.apache.commons.codec.digest.Crc16

All Implemented Interfaces:
  `Checksum`

public final class Crc16 extends Object implements 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:
  - Cyclic redundancy check
  - Catalogue of parametrised CRC algorithms with 16 bits
  - On-line CRC calculation and free library
  - crccalc

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `Crc16.Builder`
  Builds `Crc16` instances.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static Crc16`
  `arc()`
  Creates a new CRC16-CCITT Checksum.
  `static Crc16.Builder`
  `builder()`
  Creates a new builder.
  `static Crc16`
  `ccitt()`
  Creates a new CRC16-CCITT Checksum.
  `static Crc16`
  `dnp()`
  Creates a new CRC16-DNP Checksum.
  `static int[]`
  `getArcTable()`
  Gets a copy of the CRC16-CCITT table.
  `static int[]`
  `getCcittTable()`
  Gets a copy of the CRC16-CCITT table.
  `static int[]`
  `getDnpTable()`
  Gets a copy of the CRC16-DNP table.
  `static int[]`
  `getIbmSdlcTable()`
  Gets a copy of the CRC16-IBM-SDLC table.
  `static int[]`
  `getMaximTable()`
  Gets a copy of the CRC16-MAXIM table.
  `static int[]`
  `getMcrf4xxTable()`
  Gets a copy of the CRC16-MCRF4XX table.
  `static int[]`
  `getModbusTable()`
  Gets a copy of the CRC16-MODBUS table.
  `static int[]`
  `getNrsc5Table()`
  Gets a copy of the CRC16-NRSC-5 table.
  `long`
  `getValue()`
  `static Crc16`
  `ibmSdlc()`
  Creates a new CRC16-IBM-SDLC Checksum.
  `static Crc16`
  `maxim()`
  Creates a new instance for CRC16-MAXIM Checksum.
  `static Crc16`
  `mcrf4xx()`
  Creates a new instance for CRC16-MCRF4XX Checksum.
  `static Crc16`
  `modbus()`
  Creates a new instance for CRC16-MODBUS Checksum.
  `static Crc16`
  `nrsc5()`
  Creates a new instance for CRC16-NRSC-5 Checksum.
  `void`
  `reset()`
  `String`
  `toString()`
  `void`
  `update(byte[] b, int off, int len)`
  `void`
  `update(int b)`
  `static Crc16`
  `usb()`
  Creates a new instance for CRC16-USB Checksum.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### arc

    public static Crc16 arc()
    Creates a new CRC16-CCITT Checksum.
    - The init value is `0x0000`.
    - The XorOut value is `0x0000`.

    Also known as:

    - CRC-16/ARC
    - ARC
    - CRC-16
    - CRC-16/LHA
    - CRC-IBM
    Returns:
      a new CRC16-CCITT Checksum.

  - ### builder

    public static Crc16.Builder builder()
    Creates a new builder.

    Since there are so many CRC-16 variants, we do not pick a default.

    Returns:
      a new builder.

  - ### ccitt

    public static Crc16 ccitt()
    Creates a new CRC16-CCITT Checksum.
    - The init value is `0x0000`.
    - The XorOut value is `0x0000`.

    Also known as:

    - CRC-16/KERMIT
    - CRC-16/BLUETOOTH
    - CRC-16/CCITT
    - CRC-16/CCITT-TRUE
    - CRC-16/V-41-LSB
    - CRC-CCITT
    - KERMIT
    Returns:
      a new CRC16-CCITT Checksum.

  - ### dnp

    public static Crc16 dnp()
    Creates a new CRC16-DNP Checksum.
    - The init value is `0x0000`.
    - The XorOut value is `0xFFFF`.
    Returns:
      a new CRC16-DNP Checksum.

  - ### getArcTable

    public static int[] getArcTable()
    Gets a copy of the CRC16-CCITT table.
    Returns:
      a copy of the CCRC16-CITT table.

  - ### getCcittTable

    public static int[] getCcittTable()
    Gets a copy of the CRC16-CCITT table.
    Returns:
      a copy of the CCRC16-CITT table.

  - ### getDnpTable

    public static int[] getDnpTable()
    Gets a copy of the CRC16-DNP table.
    Returns:
      a copy of the CCRC16-DNP table.

  - ### getIbmSdlcTable

    public static int[] getIbmSdlcTable()
    Gets a copy of the CRC16-IBM-SDLC table.
    Returns:
      a copy of the CRC16-IBM-SDLC table.

  - ### getMaximTable

    public static int[] getMaximTable()
    Gets a copy of the CRC16-MAXIM table.
    Returns:
      a copy of the CRC16-MAXIM table.

  - ### getMcrf4xxTable

    public static int[] getMcrf4xxTable()
    Gets a copy of the CRC16-MCRF4XX table.
    Returns:
      a copy of the CRC16-MCRF4XX table.

  - ### getModbusTable

    public static int[] getModbusTable()
    Gets a copy of the CRC16-MODBUS table.
    Returns:
      a copy of the CRC16-MODBUS table.

  - ### getNrsc5Table

    public static int[] getNrsc5Table()
    Gets a copy of the CRC16-NRSC-5 table.
    Returns:
      a copy of the CRC16-NRSC-5 table.

  - ### ibmSdlc

    public static Crc16 ibmSdlc()
    Creates a new CRC16-IBM-SDLC Checksum.
    - The init value is `0xFFFF`.
    - The XorOut value is `0xFFFF`.

    Also known as:

    - CRC-16/IBM-SDLC
    - CRC-16/ISO-HDLC
    - CRC-16/ISO-IEC-14443-3-B
    - CRC-16/X-25
    - CRC-B
    - X-25
    Returns:
      a new CRC16-IBM-SDLC Checksum.

  - ### maxim

    public static Crc16 maxim()
    Creates a new instance for CRC16-MAXIM 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 `0xFFFF`.

    Also known as:

    - CRC-16/MAXIM-DOW
    Returns:
      a new CRC16-MAXIM Checksum.

  - ### mcrf4xx

    public static Crc16 mcrf4xx()
    Creates a new instance for CRC16-MCRF4XX Checksum.
    - The init value is `0xFFFF`.
    - The XorOut value is `0x0000`.
    Returns:
      a new CRC16-MCRF4XX Checksum.

  - ### modbus

    public static Crc16 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.

  - ### nrsc5

    public static Crc16 nrsc5()
    Creates a new instance for CRC16-NRSC-5 Checksum.
    - The init value is `0xFFFF`.
    - The XorOut value is `0x0000`.
    Returns:
      a new CRC16-NRSC-5 Checksum.

  - ### usb

    public static Crc16 usb()
    Creates a new instance for CRC16-USB Checksum.
    - The init value is `0xFFFF`.
    - The XorOut value is `0xFFFF`.
    Returns:
      a new CRC16-USB Checksum.

  - ### getValue

    public long getValue()
    Specified by:
      `getValue` in interface `Checksum`

  - ### reset

    public void reset()
    Specified by:
      `reset` in interface `Checksum`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### update

    public void update(byte[] b, int off, int len)
    Specified by:
      `update` in interface `Checksum`

  - ### update

    public void update(int b)
    Specified by:
      `update` in interface `Checksum`