# `pwnlib.util.crc` — Calculating CRC-sums

Module for calculating CRC-sums.

Contains all crc implementations know on the interwebz. For most implementations it contains only the core crc algorithm and not e.g. padding schemes.

It is horribly slow, as implements a naive algorithm working direclty on bit polynomials. This class is exposed as BitPolynom.

The current algorithm is super-linear and takes about 4 seconds to calculate the crc32-sum of `'A'*40000`.

An obvious optimization would be to actually generate some lookup-tables.

This doctest is to ensure that the known data are accurate:

    >>> known = sys.modules['pwnlib.util.crc.known']
    >>> known.all_crcs == known.generate()
    True

class pwnlib.util.crc.BitPolynom(n)

  Class for representing GF(2)[X], i.e. the field of polynomials over GF(2).

  In practice the polynomials are represented as numbers such that x**n corresponds to 1 << n. In this representation calculations are easy: Just do everything as normal, but forget about everything the carries.

  Addition becomes xor and multiplication becomes carry-less multiplication.

  Examples

      >>> p1 = BitPolynom("x**3 + x + 1")
      >>> p1
      BitPolynom('x**3 + x + 1')
      >>> int(p1)
      11
      >>> p1 == BitPolynom(11)
      True
      >>> p2 = BitPolynom("x**2 + x + 1")
      >>> p1 + p2
      BitPolynom('x**3 + x**2')
      >>> p1 * p2
      BitPolynom('x**5 + x**4 + 1')
      >>> p1 // p2
      BitPolynom('x + 1')
      >>> p1 % p2
      BitPolynom('x')
      >>> d, r = divmod(p1, p2)
      >>> d * p2 + r == p1
      True
      >>> BitPolynom(-1)
      Traceback (most recent call last):
          ...
      ValueError: Polynomials cannot be negative: -1
      >>> BitPolynom('y')
      Traceback (most recent call last):
          ...
      ValueError: Not a valid polynomial: y

  __eq__(other)

    Return self==value.

  __hash__()

    Return hash(self).

  __init__(n)
  __or__(other)

    Return self|value.

  __repr__()

    Return repr(self).

  __ror__(other)

    Return value|self.

  degree()

    Returns the degree of the polynomial.

    Examples

        >>> BitPolynom(0).degree()
        0
        >>> BitPolynom(1).degree()
        0
        >>> BitPolynom(2).degree()
        1
        >>> BitPolynom(7).degree()
        2
        >>> BitPolynom((1 << 10) - 1).degree()
        9
        >>> BitPolynom(1 << 10).degree()
        10

  __weakref__

    list of weak references to the object

pwnlib.util.crc.cksum(data) → int

  Calculates the same checksum as returned by the UNIX-tool `cksum`.

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(cksum(b'123456789'))
      930766865

pwnlib.util.crc.crc_10_atm(data) → int

  Calculates the crc_10_atm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x233

  - width = 10

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-10-atm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_10_atm(b'123456789'))
      409

pwnlib.util.crc.crc_10_cdma2000(data) → int

  Calculates the crc_10_cdma2000 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x3d9

  - width = 10

  - init = 0x3ff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-10-cdma2000

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_10_cdma2000(b'123456789'))
      563

pwnlib.util.crc.crc_10_gsm(data) → int

  Calculates the crc_10_gsm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x175

  - width = 10

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x3ff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-10-gsm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_10_gsm(b'123456789'))
      298

pwnlib.util.crc.crc_11_flexray(data) → int

  Calculates the crc_11_flexray checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x385

  - width = 11

  - init = 0x1a

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-11-flexray

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_11_flexray(b'123456789'))
      1443

pwnlib.util.crc.crc_11_umts(data) → int

  Calculates the crc_11_umts checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x307

  - width = 11

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-11-umts

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_11_umts(b'123456789'))
      97

pwnlib.util.crc.crc_12_cdma2000(data) → int

  Calculates the crc_12_cdma2000 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xf13

  - width = 12

  - init = 0xfff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-12-cdma2000

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_12_cdma2000(b'123456789'))
      3405

pwnlib.util.crc.crc_12_dect(data) → int

  Calculates the crc_12_dect checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x80f

  - width = 12

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-12-dect

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_12_dect(b'123456789'))
      3931

pwnlib.util.crc.crc_12_gsm(data) → int

  Calculates the crc_12_gsm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xd31

  - width = 12

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0xfff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-12-gsm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_12_gsm(b'123456789'))
      2868

pwnlib.util.crc.crc_12_umts(data) → int

  Calculates the crc_12_umts checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x80f

  - width = 12

  - init = 0x0

  - refin = False

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-12-umts

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_12_umts(b'123456789'))
      3503

pwnlib.util.crc.crc_13_bbc(data) → int

  Calculates the crc_13_bbc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1cf5

  - width = 13

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-13-bbc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_13_bbc(b'123456789'))
      1274

pwnlib.util.crc.crc_14_darc(data) → int

  Calculates the crc_14_darc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x805

  - width = 14

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-14-darc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_14_darc(b'123456789'))
      2093

pwnlib.util.crc.crc_14_gsm(data) → int

  Calculates the crc_14_gsm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x202d

  - width = 14

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x3fff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-14-gsm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_14_gsm(b'123456789'))
      12462

pwnlib.util.crc.crc_15_can(data) → int

  Calculates the crc_15_can checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4599

  - width = 15

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-15-can

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_15_can(b'123456789'))
      1438

pwnlib.util.crc.crc_15_mpt1327(data) → int

  Calculates the crc_15_mpt1327 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x6815

  - width = 15

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x1

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-15-mpt1327

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_15_mpt1327(b'123456789'))
      9574

pwnlib.util.crc.crc_16_arc(data) → int

  Calculates the crc_16_arc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8005

  - width = 16

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-arc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_arc(b'123456789'))
      47933

pwnlib.util.crc.crc_16_cdma2000(data) → int

  Calculates the crc_16_cdma2000 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xc867

  - width = 16

  - init = 0xffff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-cdma2000

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_cdma2000(b'123456789'))
      19462

pwnlib.util.crc.crc_16_cms(data) → int

  Calculates the crc_16_cms checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8005

  - width = 16

  - init = 0xffff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-cms

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_cms(b'123456789'))
      44775

pwnlib.util.crc.crc_16_dds_110(data) → int

  Calculates the crc_16_dds_110 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8005

  - width = 16

  - init = 0x800d

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-dds-110

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_dds_110(b'123456789'))
      40655

pwnlib.util.crc.crc_16_dect_r(data) → int

  Calculates the crc_16_dect_r checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x589

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x1

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-dect-r

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_dect_r(b'123456789'))
      126

pwnlib.util.crc.crc_16_dect_x(data) → int

  Calculates the crc_16_dect_x checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x589

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-dect-x

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_dect_x(b'123456789'))
      127

pwnlib.util.crc.crc_16_dnp(data) → int

  Calculates the crc_16_dnp checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x3d65

  - width = 16

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0xffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-dnp

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_dnp(b'123456789'))
      60034

pwnlib.util.crc.crc_16_en_13757(data) → int

  Calculates the crc_16_en_13757 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x3d65

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0xffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-en-13757

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_en_13757(b'123456789'))
      49847

pwnlib.util.crc.crc_16_genibus(data) → int

  Calculates the crc_16_genibus checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0xffff

  - refin = False

  - refout = False

  - xorout = 0xffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-genibus

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_genibus(b'123456789'))
      54862

pwnlib.util.crc.crc_16_gsm(data) → int

  Calculates the crc_16_gsm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0xffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-gsm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_gsm(b'123456789'))
      52796

pwnlib.util.crc.crc_16_ibm_3740(data) → int

  Calculates the crc_16_ibm_3740 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0xffff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-ibm-3740

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_ibm_3740(b'123456789'))
      10673

pwnlib.util.crc.crc_16_ibm_sdlc(data) → int

  Calculates the crc_16_ibm_sdlc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0xffff

  - refin = True

  - refout = True

  - xorout = 0xffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-ibm-sdlc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_ibm_sdlc(b'123456789'))
      36974

pwnlib.util.crc.crc_16_iso_iec_14443_3_a(data) → int

  Calculates the crc_16_iso_iec_14443_3_a checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0xc6c6

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-iso-iec-14443-3-a

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_iso_iec_14443_3_a(b'123456789'))
      48901

pwnlib.util.crc.crc_16_kermit(data) → int

  Calculates the crc_16_kermit checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-kermit

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_kermit(b'123456789'))
      8585

pwnlib.util.crc.crc_16_lj1200(data) → int

  Calculates the crc_16_lj1200 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x6f63

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-lj1200

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_lj1200(b'123456789'))
      48628

pwnlib.util.crc.crc_16_m17(data) → int

  Calculates the crc_16_m17 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x5935

  - width = 16

  - init = 0xffff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-m17

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_m17(b'123456789'))
      30507

pwnlib.util.crc.crc_16_maxim_dow(data) → int

  Calculates the crc_16_maxim_dow checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8005

  - width = 16

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0xffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-maxim-dow

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_maxim_dow(b'123456789'))
      17602

pwnlib.util.crc.crc_16_mcrf4xx(data) → int

  Calculates the crc_16_mcrf4xx checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0xffff

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-mcrf4xx

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_mcrf4xx(b'123456789'))
      28561

pwnlib.util.crc.crc_16_modbus(data) → int

  Calculates the crc_16_modbus checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8005

  - width = 16

  - init = 0xffff

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-modbus

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_modbus(b'123456789'))
      19255

pwnlib.util.crc.crc_16_nrsc_5(data) → int

  Calculates the crc_16_nrsc_5 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x80b

  - width = 16

  - init = 0xffff

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-nrsc-5

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_nrsc_5(b'123456789'))
      41062

pwnlib.util.crc.crc_16_opensafety_a(data) → int

  Calculates the crc_16_opensafety_a checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x5935

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-opensafety-a

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_opensafety_a(b'123456789'))
      23864

pwnlib.util.crc.crc_16_opensafety_b(data) → int

  Calculates the crc_16_opensafety_b checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x755b

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-opensafety-b

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_opensafety_b(b'123456789'))
      8446

pwnlib.util.crc.crc_16_profibus(data) → int

  Calculates the crc_16_profibus checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1dcf

  - width = 16

  - init = 0xffff

  - refin = False

  - refout = False

  - xorout = 0xffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-profibus

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_profibus(b'123456789'))
      43033

pwnlib.util.crc.crc_16_riello(data) → int

  Calculates the crc_16_riello checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0xb2aa

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-riello

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_riello(b'123456789'))
      25552

pwnlib.util.crc.crc_16_spi_fujitsu(data) → int

  Calculates the crc_16_spi_fujitsu checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0x1d0f

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-spi-fujitsu

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_spi_fujitsu(b'123456789'))
      58828

pwnlib.util.crc.crc_16_t10_dif(data) → int

  Calculates the crc_16_t10_dif checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8bb7

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-t10-dif

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_t10_dif(b'123456789'))
      53467

pwnlib.util.crc.crc_16_teledisk(data) → int

  Calculates the crc_16_teledisk checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xa097

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-teledisk

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_teledisk(b'123456789'))
      4019

pwnlib.util.crc.crc_16_tms37157(data) → int

  Calculates the crc_16_tms37157 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0x89ec

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-tms37157

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_tms37157(b'123456789'))
      9905

pwnlib.util.crc.crc_16_umts(data) → int

  Calculates the crc_16_umts checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8005

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-umts

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_umts(b'123456789'))
      65256

pwnlib.util.crc.crc_16_usb(data) → int

  Calculates the crc_16_usb checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8005

  - width = 16

  - init = 0xffff

  - refin = True

  - refout = True

  - xorout = 0xffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-usb

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_usb(b'123456789'))
      46280

pwnlib.util.crc.crc_16_xmodem(data) → int

  Calculates the crc_16_xmodem checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1021

  - width = 16

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-16-xmodem

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_16_xmodem(b'123456789'))
      12739

pwnlib.util.crc.crc_17_can_fd(data) → int

  Calculates the crc_17_can_fd checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1685b

  - width = 17

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-17-can-fd

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_17_can_fd(b'123456789'))
      20227

pwnlib.util.crc.crc_21_can_fd(data) → int

  Calculates the crc_21_can_fd checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x102899

  - width = 21

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-21-can-fd

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_21_can_fd(b'123456789'))
      972865

pwnlib.util.crc.crc_24_ble(data) → int

  Calculates the crc_24_ble checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x65b

  - width = 24

  - init = 0x555555

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-24-ble

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_24_ble(b'123456789'))
      12737110

pwnlib.util.crc.crc_24_flexray_a(data) → int

  Calculates the crc_24_flexray_a checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x5d6dcb

  - width = 24

  - init = 0xfedcba

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-24-flexray-a

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_24_flexray_a(b'123456789'))
      7961021

pwnlib.util.crc.crc_24_flexray_b(data) → int

  Calculates the crc_24_flexray_b checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x5d6dcb

  - width = 24

  - init = 0xabcdef

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-24-flexray-b

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_24_flexray_b(b'123456789'))
      2040760

pwnlib.util.crc.crc_24_interlaken(data) → int

  Calculates the crc_24_interlaken checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x328b63

  - width = 24

  - init = 0xffffff

  - refin = False

  - refout = False

  - xorout = 0xffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-24-interlaken

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_24_interlaken(b'123456789'))
      11858918

pwnlib.util.crc.crc_24_lte_a(data) → int

  Calculates the crc_24_lte_a checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x864cfb

  - width = 24

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-24-lte-a

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_24_lte_a(b'123456789'))
      13494019

pwnlib.util.crc.crc_24_lte_b(data) → int

  Calculates the crc_24_lte_b checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x800063

  - width = 24

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-24-lte-b

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_24_lte_b(b'123456789'))
      2355026

pwnlib.util.crc.crc_24_openpgp(data) → int

  Calculates the crc_24_openpgp checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x864cfb

  - width = 24

  - init = 0xb704ce

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-24-openpgp

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_24_openpgp(b'123456789'))
      2215682

pwnlib.util.crc.crc_24_os_9(data) → int

  Calculates the crc_24_os_9 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x800063

  - width = 24

  - init = 0xffffff

  - refin = False

  - refout = False

  - xorout = 0xffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-24-os-9

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_24_os_9(b'123456789'))
      2101157

pwnlib.util.crc.crc_30_cdma(data) → int

  Calculates the crc_30_cdma checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x2030b9c7

  - width = 30

  - init = 0x3fffffff

  - refin = False

  - refout = False

  - xorout = 0x3fffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-30-cdma

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_30_cdma(b'123456789'))
      79907519

pwnlib.util.crc.crc_31_philips(data) → int

  Calculates the crc_31_philips checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4c11db7

  - width = 31

  - init = 0x7fffffff

  - refin = False

  - refout = False

  - xorout = 0x7fffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-31-philips

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_31_philips(b'123456789'))
      216654956

pwnlib.util.crc.crc_32_aixm(data) → int

  Calculates the crc_32_aixm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x814141ab

  - width = 32

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-aixm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_aixm(b'123456789'))
      806403967

pwnlib.util.crc.crc_32_autosar(data) → int

  Calculates the crc_32_autosar checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xf4acfb13

  - width = 32

  - init = 0xffffffff

  - refin = True

  - refout = True

  - xorout = 0xffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-autosar

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_autosar(b'123456789'))
      379048042

pwnlib.util.crc.crc_32_base91_d(data) → int

  Calculates the crc_32_base91_d checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xa833982b

  - width = 32

  - init = 0xffffffff

  - refin = True

  - refout = True

  - xorout = 0xffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-base91-d

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_base91_d(b'123456789'))
      2268157302

pwnlib.util.crc.crc_32_bzip2(data) → int

  Calculates the crc_32_bzip2 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4c11db7

  - width = 32

  - init = 0xffffffff

  - refin = False

  - refout = False

  - xorout = 0xffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-bzip2

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_bzip2(b'123456789'))
      4236843288

pwnlib.util.crc.crc_32_cd_rom_edc(data) → int

  Calculates the crc_32_cd_rom_edc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x8001801b

  - width = 32

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-cd-rom-edc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_cd_rom_edc(b'123456789'))
      1858268612

pwnlib.util.crc.crc_32_cksum(data) → int

  Calculates the crc_32_cksum checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4c11db7

  - width = 32

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0xffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-cksum

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_cksum(b'123456789'))
      1985902208

pwnlib.util.crc.crc_32_iscsi(data) → int

  Calculates the crc_32_iscsi checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1edc6f41

  - width = 32

  - init = 0xffffffff

  - refin = True

  - refout = True

  - xorout = 0xffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-iscsi

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_iscsi(b'123456789'))
      3808858755

pwnlib.util.crc.crc_32_iso_hdlc(data) → int

  Calculates the crc_32_iso_hdlc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4c11db7

  - width = 32

  - init = 0xffffffff

  - refin = True

  - refout = True

  - xorout = 0xffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-iso-hdlc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_iso_hdlc(b'123456789'))
      3421780262

pwnlib.util.crc.crc_32_jamcrc(data) → int

  Calculates the crc_32_jamcrc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4c11db7

  - width = 32

  - init = 0xffffffff

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-jamcrc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_jamcrc(b'123456789'))
      873187033

pwnlib.util.crc.crc_32_mef(data) → int

  Calculates the crc_32_mef checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x741b8cd7

  - width = 32

  - init = 0xffffffff

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-mef

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_mef(b'123456789'))
      3535941457

pwnlib.util.crc.crc_32_mpeg_2(data) → int

  Calculates the crc_32_mpeg_2 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4c11db7

  - width = 32

  - init = 0xffffffff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-mpeg-2

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_mpeg_2(b'123456789'))
      58124007

pwnlib.util.crc.crc_32_xfer(data) → int

  Calculates the crc_32_xfer checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xaf

  - width = 32

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-32-xfer

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_32_xfer(b'123456789'))
      3171672888

pwnlib.util.crc.crc_3_gsm(data) → int

  Calculates the crc_3_gsm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x3

  - width = 3

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x7

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-3-gsm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_3_gsm(b'123456789'))
      4

pwnlib.util.crc.crc_3_rohc(data) → int

  Calculates the crc_3_rohc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x3

  - width = 3

  - init = 0x7

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-3-rohc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_3_rohc(b'123456789'))
      6

pwnlib.util.crc.crc_40_gsm(data) → int

  Calculates the crc_40_gsm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4820009

  - width = 40

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0xffffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-40-gsm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_40_gsm(b'123456789'))
      910907393606

pwnlib.util.crc.crc_4_g_704(data) → int

  Calculates the crc_4_g_704 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x3

  - width = 4

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-4-g-704

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_4_g_704(b'123456789'))
      7

pwnlib.util.crc.crc_4_interlaken(data) → int

  Calculates the crc_4_interlaken checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x3

  - width = 4

  - init = 0xf

  - refin = False

  - refout = False

  - xorout = 0xf

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-4-interlaken

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_4_interlaken(b'123456789'))
      11

pwnlib.util.crc.crc_5_epc_c1g2(data) → int

  Calculates the crc_5_epc_c1g2 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x9

  - width = 5

  - init = 0x9

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-5-epc-c1g2

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_5_epc_c1g2(b'123456789'))
      0

pwnlib.util.crc.crc_5_g_704(data) → int

  Calculates the crc_5_g_704 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x15

  - width = 5

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-5-g-704

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_5_g_704(b'123456789'))
      7

pwnlib.util.crc.crc_5_usb(data) → int

  Calculates the crc_5_usb checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x5

  - width = 5

  - init = 0x1f

  - refin = True

  - refout = True

  - xorout = 0x1f

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-5-usb

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_5_usb(b'123456789'))
      25

pwnlib.util.crc.crc_64_ecma_182(data) → int

  Calculates the crc_64_ecma_182 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x42f0e1eba9ea3693

  - width = 64

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-64-ecma-182

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_64_ecma_182(b'123456789'))
      7800480153909949255

pwnlib.util.crc.crc_64_go_iso(data) → int

  Calculates the crc_64_go_iso checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1b

  - width = 64

  - init = 0xffffffffffffffff

  - refin = True

  - refout = True

  - xorout = 0xffffffffffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-64-go-iso

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_64_go_iso(b'123456789'))
      13333283586479230977

pwnlib.util.crc.crc_64_ms(data) → int

  Calculates the crc_64_ms checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x259c84cba6426349

  - width = 64

  - init = 0xffffffffffffffff

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-64-ms

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_64_ms(b'123456789'))
      8490612747469246186

pwnlib.util.crc.crc_64_we(data) → int

  Calculates the crc_64_we checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x42f0e1eba9ea3693

  - width = 64

  - init = 0xffffffffffffffff

  - refin = False

  - refout = False

  - xorout = 0xffffffffffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-64-we

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_64_we(b'123456789'))
      7128171145767219210

pwnlib.util.crc.crc_64_xz(data) → int

  Calculates the crc_64_xz checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x42f0e1eba9ea3693

  - width = 64

  - init = 0xffffffffffffffff

  - refin = True

  - refout = True

  - xorout = 0xffffffffffffffff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-64-xz

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_64_xz(b'123456789'))
      11051210869376104954

pwnlib.util.crc.crc_6_cdma2000_a(data) → int

  Calculates the crc_6_cdma2000_a checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x27

  - width = 6

  - init = 0x3f

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-6-cdma2000-a

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_6_cdma2000_a(b'123456789'))
      13

pwnlib.util.crc.crc_6_cdma2000_b(data) → int

  Calculates the crc_6_cdma2000_b checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x7

  - width = 6

  - init = 0x3f

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-6-cdma2000-b

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_6_cdma2000_b(b'123456789'))
      59

pwnlib.util.crc.crc_6_darc(data) → int

  Calculates the crc_6_darc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x19

  - width = 6

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-6-darc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_6_darc(b'123456789'))
      38

pwnlib.util.crc.crc_6_g_704(data) → int

  Calculates the crc_6_g_704 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x3

  - width = 6

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-6-g-704

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_6_g_704(b'123456789'))
      6

pwnlib.util.crc.crc_6_gsm(data) → int

  Calculates the crc_6_gsm checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x2f

  - width = 6

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x3f

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-6-gsm

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_6_gsm(b'123456789'))
      19

pwnlib.util.crc.crc_7_mmc(data) → int

  Calculates the crc_7_mmc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x9

  - width = 7

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-7-mmc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_7_mmc(b'123456789'))
      117

pwnlib.util.crc.crc_7_rohc(data) → int

  Calculates the crc_7_rohc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x4f

  - width = 7

  - init = 0x7f

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-7-rohc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_7_rohc(b'123456789'))
      83

pwnlib.util.crc.crc_7_umts(data) → int

  Calculates the crc_7_umts checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x45

  - width = 7

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-7-umts

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_7_umts(b'123456789'))
      97

pwnlib.util.crc.crc_82_darc(data) → int

  Calculates the crc_82_darc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x308c0111011401440411

  - width = 82

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-82-darc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_82_darc(b'123456789'))
      749237524598872659187218

pwnlib.util.crc.crc_8_autosar(data) → int

  Calculates the crc_8_autosar checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x2f

  - width = 8

  - init = 0xff

  - refin = False

  - refout = False

  - xorout = 0xff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-autosar

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_autosar(b'123456789'))
      223

pwnlib.util.crc.crc_8_bluetooth(data) → int

  Calculates the crc_8_bluetooth checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xa7

  - width = 8

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-bluetooth

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_bluetooth(b'123456789'))
      38

pwnlib.util.crc.crc_8_cdma2000(data) → int

  Calculates the crc_8_cdma2000 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x9b

  - width = 8

  - init = 0xff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-cdma2000

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_cdma2000(b'123456789'))
      218

pwnlib.util.crc.crc_8_darc(data) → int

  Calculates the crc_8_darc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x39

  - width = 8

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-darc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_darc(b'123456789'))
      21

pwnlib.util.crc.crc_8_dvb_s2(data) → int

  Calculates the crc_8_dvb_s2 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0xd5

  - width = 8

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-dvb-s2

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_dvb_s2(b'123456789'))
      188

pwnlib.util.crc.crc_8_gsm_a(data) → int

  Calculates the crc_8_gsm_a checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1d

  - width = 8

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-gsm-a

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_gsm_a(b'123456789'))
      55

pwnlib.util.crc.crc_8_gsm_b(data) → int

  Calculates the crc_8_gsm_b checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x49

  - width = 8

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0xff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-gsm-b

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_gsm_b(b'123456789'))
      148

pwnlib.util.crc.crc_8_hitag(data) → int

  Calculates the crc_8_hitag checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1d

  - width = 8

  - init = 0xff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-hitag

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_hitag(b'123456789'))
      180

pwnlib.util.crc.crc_8_i_432_1(data) → int

  Calculates the crc_8_i_432_1 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x7

  - width = 8

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x55

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-i-432-1

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_i_432_1(b'123456789'))
      161

pwnlib.util.crc.crc_8_i_code(data) → int

  Calculates the crc_8_i_code checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1d

  - width = 8

  - init = 0xfd

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-i-code

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_i_code(b'123456789'))
      126

pwnlib.util.crc.crc_8_lte(data) → int

  Calculates the crc_8_lte checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x9b

  - width = 8

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-lte

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_lte(b'123456789'))
      234

pwnlib.util.crc.crc_8_maxim_dow(data) → int

  Calculates the crc_8_maxim_dow checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x31

  - width = 8

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-maxim-dow

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_maxim_dow(b'123456789'))
      161

pwnlib.util.crc.crc_8_mifare_mad(data) → int

  Calculates the crc_8_mifare_mad checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1d

  - width = 8

  - init = 0xc7

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-mifare-mad

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_mifare_mad(b'123456789'))
      153

pwnlib.util.crc.crc_8_nrsc_5(data) → int

  Calculates the crc_8_nrsc_5 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x31

  - width = 8

  - init = 0xff

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-nrsc-5

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_nrsc_5(b'123456789'))
      247

pwnlib.util.crc.crc_8_opensafety(data) → int

  Calculates the crc_8_opensafety checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x2f

  - width = 8

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-opensafety

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_opensafety(b'123456789'))
      62

pwnlib.util.crc.crc_8_rohc(data) → int

  Calculates the crc_8_rohc checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x7

  - width = 8

  - init = 0xff

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-rohc

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_rohc(b'123456789'))
      208

pwnlib.util.crc.crc_8_sae_j1850(data) → int

  Calculates the crc_8_sae_j1850 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1d

  - width = 8

  - init = 0xff

  - refin = False

  - refout = False

  - xorout = 0xff

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-sae-j1850

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_sae_j1850(b'123456789'))
      75

pwnlib.util.crc.crc_8_smbus(data) → int

  Calculates the crc_8_smbus checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x7

  - width = 8

  - init = 0x0

  - refin = False

  - refout = False

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-smbus

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_smbus(b'123456789'))
      244

pwnlib.util.crc.crc_8_tech_3250(data) → int

  Calculates the crc_8_tech_3250 checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x1d

  - width = 8

  - init = 0xff

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-tech-3250

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_tech_3250(b'123456789'))
      151

pwnlib.util.crc.crc_8_wcdma(data) → int

  Calculates the crc_8_wcdma checksum.

  This is simply the `generic_crc()` with these frozen arguments:

  - polynom = 0x9b

  - width = 8

  - init = 0x0

  - refin = True

  - refout = True

  - xorout = 0x0

  See also: https://reveng.sourceforge.io/crc-catalogue/all.htm#crc.cat.crc-8-wcdma

  Parameters:

    data (str) – The data to checksum.

  Example

      >>> print(crc_8_wcdma(b'123456789'))
      37

pwnlib.util.crc.find_crc_function(data, checksum)

  Finds all known CRC functions that hashes a piece of data into a specific checksum. It does this by trying all known CRC functions one after the other.

  Parameters:

    data (str) – Data for which the checksum is known.

  Example

      >>> find_crc_function(b'test', 46197)
      [<function crc_crc_16_dnp at ...>]

pwnlib.util.crc.generic_crc(data, polynom, width, init, refin, refout, xorout)

  A generic CRC-sum function.

  This is suitable to use with: https://reveng.sourceforge.io/crc-catalogue/all.htm

  The “check” value in the document is the CRC-sum of the string “123456789”.

  Parameters:

    - data (str) – The data to calculate the CRC-sum of. This should either be a string or a list of bits.

    - polynom (int) – The polynomial to use.

    - init (int) – If the CRC-sum was calculated in hardware, then this would b the initial value of the checksum register.

    - refin (bool) – Should the input bytes be reflected?

    - refout (bool) – Should the checksum be reflected?

    - xorout (int) – The value to xor the checksum with before outputting