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.
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.
-
pwnlib.util.crc.
generic_crc
(data, polynom, width, init, refin, refout, xorout)[source]¶ A generic CRC-sum function.
This is suitable to use with: http://reveng.sourceforge.net/crc-catalogue/all.htm
The “check” value in the document is the CRC-sum of the string “123456789”.
Parameters: - data (bytes, str, list) – 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
-
pwnlib.util.crc.
cksum
(data) → int[source]¶ Calculates the same checksum as returned by the UNIX-tool
cksum
.Parameters: data (bytes, str) – The data to checksum. Example
>>> print(cksum('123456789')) 930766865
-
pwnlib.util.crc.
find_crc_function
(data, checksum)[source]¶ 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('test', 46197) [<function crc_crc_16_dnp at ...>]
-
pwnlib.util.crc.
arc
(data) → int[source]¶ Calculates the 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.16
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(arc('123456789')) 47933
-
pwnlib.util.crc.
crc_10
(data) → int[source]¶ Calculates the crc_10 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.10
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_10('123456789')) 409
-
pwnlib.util.crc.
crc_10_cdma2000
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-10-cdma2000
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_10_cdma2000('123456789')) 563
-
pwnlib.util.crc.
crc_11
(data) → int[source]¶ Calculates the crc_11 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.11
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_11('123456789')) 1443
-
pwnlib.util.crc.
crc_12_3gpp
(data) → int[source]¶ Calculates the crc_12_3gpp 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.12
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_12_3gpp('123456789')) 3503
-
pwnlib.util.crc.
crc_12_cdma2000
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-12-cdma2000
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_12_cdma2000('123456789')) 3405
-
pwnlib.util.crc.
crc_12_dect
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-12-dect
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_12_dect('123456789')) 3931
-
pwnlib.util.crc.
crc_13_bbc
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.13
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_13_bbc('123456789')) 1274
-
pwnlib.util.crc.
crc_14_darc
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.14
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_14_darc('123456789')) 2093
-
pwnlib.util.crc.
crc_15
(data) → int[source]¶ Calculates the crc_15 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.15
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_15('123456789')) 1438
-
pwnlib.util.crc.
crc_15_mpt1327
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-15-mpt1327
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_15_mpt1327('123456789')) 9574
-
pwnlib.util.crc.
crc_16_aug_ccitt
(data) → int[source]¶ Calculates the crc_16_aug_ccitt 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-aug-ccitt
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_aug_ccitt('123456789')) 58828
-
pwnlib.util.crc.
crc_16_buypass
(data) → int[source]¶ Calculates the crc_16_buypass 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-buypass
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_buypass('123456789')) 65256
-
pwnlib.util.crc.
crc_16_ccitt_false
(data) → int[source]¶ Calculates the crc_16_ccitt_false 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-ccitt-false
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_ccitt_false('123456789')) 10673
-
pwnlib.util.crc.
crc_16_cdma2000
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-cdma2000
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_cdma2000('123456789')) 19462
-
pwnlib.util.crc.
crc_16_dds_110
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-dds-110
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_dds_110('123456789')) 40655
-
pwnlib.util.crc.
crc_16_dect_r
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-dect-r
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_dect_r('123456789')) 126
-
pwnlib.util.crc.
crc_16_dect_x
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-dect-x
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_dect_x('123456789')) 127
-
pwnlib.util.crc.
crc_16_dnp
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-dnp
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_dnp('123456789')) 60034
-
pwnlib.util.crc.
crc_16_en_13757
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-en-13757
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_en_13757('123456789')) 49847
-
pwnlib.util.crc.
crc_16_genibus
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-genibus
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_genibus('123456789')) 54862
-
pwnlib.util.crc.
crc_16_maxim
(data) → int[source]¶ Calculates the crc_16_maxim 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-maxim
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_maxim('123456789')) 17602
-
pwnlib.util.crc.
crc_16_mcrf4xx
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-mcrf4xx
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_mcrf4xx('123456789')) 28561
-
pwnlib.util.crc.
crc_16_riello
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-riello
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_riello('123456789')) 25552
-
pwnlib.util.crc.
crc_16_t10_dif
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-t10-dif
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_t10_dif('123456789')) 53467
-
pwnlib.util.crc.
crc_16_teledisk
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-teledisk
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_teledisk('123456789')) 4019
-
pwnlib.util.crc.
crc_16_tms37157
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-tms37157
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_tms37157('123456789')) 9905
-
pwnlib.util.crc.
crc_16_usb
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-16-usb
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_16_usb('123456789')) 46280
-
pwnlib.util.crc.
crc_24
(data) → int[source]¶ Calculates the crc_24 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.24
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_24('123456789')) 2215682
-
pwnlib.util.crc.
crc_24_flexray_a
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-24-flexray-a
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_24_flexray_a('123456789')) 7961021
-
pwnlib.util.crc.
crc_24_flexray_b
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-24-flexray-b
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_24_flexray_b('123456789')) 2040760
-
pwnlib.util.crc.
crc_31_philips
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.31
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_31_philips('123456789')) 216654956
-
pwnlib.util.crc.
crc_32
(data) → int[source]¶ Calculates the crc_32 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.32
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_32('123456789')) 3421780262
-
pwnlib.util.crc.
crc_32_bzip2
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-32-bzip2
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_32_bzip2('123456789')) 4236843288
-
pwnlib.util.crc.
crc_32_mpeg_2
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-32-mpeg-2
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_32_mpeg_2('123456789')) 58124007
-
pwnlib.util.crc.
crc_32_posix
(data) → int[source]¶ Calculates the crc_32_posix 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-32-posix
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_32_posix('123456789')) 1985902208
-
pwnlib.util.crc.
crc_32c
(data) → int[source]¶ Calculates the crc_32c 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-32c
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_32c('123456789')) 3808858755
-
pwnlib.util.crc.
crc_32d
(data) → int[source]¶ Calculates the crc_32d 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-32d
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_32d('123456789')) 2268157302
-
pwnlib.util.crc.
crc_32q
(data) → int[source]¶ Calculates the crc_32q 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-32q
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_32q('123456789')) 806403967
-
pwnlib.util.crc.
crc_3_rohc
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.3
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_3_rohc('123456789')) 6
-
pwnlib.util.crc.
crc_40_gsm
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.40
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_40_gsm('123456789')) 910907393606
-
pwnlib.util.crc.
crc_4_itu
(data) → int[source]¶ Calculates the crc_4_itu 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.4
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_4_itu('123456789')) 7
-
pwnlib.util.crc.
crc_5_epc
(data) → int[source]¶ Calculates the crc_5_epc 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.5
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_5_epc('123456789')) 0
-
pwnlib.util.crc.
crc_5_itu
(data) → int[source]¶ Calculates the crc_5_itu 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-5-itu
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_5_itu('123456789')) 7
-
pwnlib.util.crc.
crc_5_usb
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-5-usb
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_5_usb('123456789')) 25
-
pwnlib.util.crc.
crc_64
(data) → int[source]¶ Calculates the crc_64 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.64
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_64('123456789')) 7800480153909949255
-
pwnlib.util.crc.
crc_64_we
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-64-we
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_64_we('123456789')) 7128171145767219210
-
pwnlib.util.crc.
crc_64_xz
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-64-xz
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_64_xz('123456789')) 11051210869376104954
-
pwnlib.util.crc.
crc_6_cdma2000_a
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.6
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_6_cdma2000_a('123456789')) 13
-
pwnlib.util.crc.
crc_6_cdma2000_b
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-6-cdma2000-b
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_6_cdma2000_b('123456789')) 59
-
pwnlib.util.crc.
crc_6_darc
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-6-darc
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_6_darc('123456789')) 38
-
pwnlib.util.crc.
crc_6_itu
(data) → int[source]¶ Calculates the crc_6_itu 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-6-itu
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_6_itu('123456789')) 6
-
pwnlib.util.crc.
crc_7
(data) → int[source]¶ Calculates the crc_7 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.7
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_7('123456789')) 117
-
pwnlib.util.crc.
crc_7_rohc
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-7-rohc
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_7_rohc('123456789')) 83
-
pwnlib.util.crc.
crc_8
(data) → int[source]¶ Calculates the crc_8 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.8
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8('123456789')) 244
-
pwnlib.util.crc.
crc_82_darc
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat-bits.82
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_82_darc('123456789')) 749237524598872659187218
-
pwnlib.util.crc.
crc_8_cdma2000
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-cdma2000
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_cdma2000('123456789')) 218
-
pwnlib.util.crc.
crc_8_darc
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-darc
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_darc('123456789')) 21
-
pwnlib.util.crc.
crc_8_dvb_s2
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-dvb-s2
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_dvb_s2('123456789')) 188
-
pwnlib.util.crc.
crc_8_ebu
(data) → int[source]¶ Calculates the crc_8_ebu 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-ebu
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_ebu('123456789')) 151
-
pwnlib.util.crc.
crc_8_i_code
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-i-code
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_i_code('123456789')) 126
-
pwnlib.util.crc.
crc_8_itu
(data) → int[source]¶ Calculates the crc_8_itu 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-itu
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_itu('123456789')) 161
-
pwnlib.util.crc.
crc_8_maxim
(data) → int[source]¶ Calculates the crc_8_maxim 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-maxim
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_maxim('123456789')) 161
-
pwnlib.util.crc.
crc_8_rohc
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-rohc
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_rohc('123456789')) 208
-
pwnlib.util.crc.
crc_8_wcdma
(data) → int[source]¶ 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-8-wdcma
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_8_wcdma('123456789')) 37
-
pwnlib.util.crc.
crc_a
(data) → int[source]¶ Calculates the crc_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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.crc-a
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(crc_a('123456789')) 48901
-
pwnlib.util.crc.
jamcrc
(data) → int[source]¶ Calculates the 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.jamcrc
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(jamcrc('123456789')) 873187033
-
pwnlib.util.crc.
kermit
(data) → int[source]¶ Calculates the 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.kermit
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(kermit('123456789')) 8585
-
pwnlib.util.crc.
modbus
(data) → int[source]¶ Calculates the 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.modbus
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(modbus('123456789')) 19255
-
pwnlib.util.crc.
x_25
(data) → int[source]¶ Calculates the x_25 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.x-25
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(x_25('123456789')) 36974
-
pwnlib.util.crc.
xfer
(data) → int[source]¶ Calculates the 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.xfer
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(xfer('123456789')) 3171672888
-
pwnlib.util.crc.
xmodem
(data) → int[source]¶ Calculates the 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: http://reveng.sourceforge.net/crc-catalogue/all.htm#crc.cat.xmodem
Parameters: data (bytes, str) – The data to checksum. Example
>>> print(xmodem('123456789')) 12739