annotate cutils/crcmod/python3/predefined.py @ 386:f045d46e9f3d

treesum: also collect the CRC checksum when reading .treesum files and test for them
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 17 May 2025 22:41:22 +0200
parents 5c5c0c5a7402
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 #-----------------------------------------------------------------------------
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2 # Copyright (c) 2010 Craig McQueen
186
5c5c0c5a7402 Sync with latest crcmod2
Franz Glasner <fzglas.hg@dom66.de>
parents: 182
diff changeset
3 # Copyright (c) 2025 Franz Glasner
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4 #
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
6 # of this software and associated documentation files (the "Software"), to deal
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
7 # in the Software without restriction, including without limitation the rights
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
9 # copies of the Software, and to permit persons to whom the Software is
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
10 # furnished to do so, subject to the following conditions:
182
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
11 #
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
12 # The above copyright notice and this permission notice shall be included in
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
13 # all copies or substantial portions of the Software.
182
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
14 #
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
21 # SOFTWARE.
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
22 #-----------------------------------------------------------------------------
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
23 '''
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
24 crcmod.predefined defines some well-known CRC algorithms.
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
25
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
26 To use it, e.g.:
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
27 import crcmod.predefined
182
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
28
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
29 crc32func = crcmod.predefined.mkPredefinedCrcFun("crc-32")
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
30 crc32class = crcmod.predefined.PredefinedCrc("crc-32")
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
31
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
32 crcmod.predefined.Crc is an alias for crcmod.predefined.PredefinedCrc
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
33 But if doing 'from crc.predefined import *', only PredefinedCrc is imported.
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
34 '''
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
35
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
36 # local imports
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
37 from . import crcmod
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
38
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
39 __all__ = [
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
40 'PredefinedCrc',
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
41 'mkPredefinedCrcFun',
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
42 ]
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
43
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
44 REVERSE = True
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
45 NON_REVERSE = False
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
46
182
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
47 #
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
48 # The following table defines the parameters of well-known CRC algorithms.
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
49 # The "Check" value is the CRC for the ASCII byte sequence b"123456789". It
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
50 # can be used for unit tests.
182
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
51 #
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
52 # See also:
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
53 # - https://en.wikipedia.org/wiki/Cyclic_redundancy_check
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
54 # - https://reveng.sourceforge.io/crc-catalogue/all.htm
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
55 # - http://users.ece.cmu.edu/~koopman/crc/index.html
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
56 # - https://pycrc.org/models.html
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
57 # - https://github.com/marzooqy/anycrc
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
58 #
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
59 _crc_definitions_table = [
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
60 # Name Identifier-name, Poly Reverse Init-value XOR-out Check
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
61 [ 'crc-8', 'Crc8', 0x107, NON_REVERSE, 0x00, 0x00, 0xF4, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
62 [ 'crc-8-darc', 'Crc8Darc', 0x139, REVERSE, 0x00, 0x00, 0x15, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
63 [ 'crc-8-i-code', 'Crc8ICode', 0x11D, NON_REVERSE, 0xFD, 0x00, 0x7E, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
64 [ 'crc-8-itu', 'Crc8Itu', 0x107, NON_REVERSE, 0x55, 0x55, 0xA1, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
65 [ 'crc-8-maxim', 'Crc8Maxim', 0x131, REVERSE, 0x00, 0x00, 0xA1, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
66 [ 'crc-8-rohc', 'Crc8Rohc', 0x107, REVERSE, 0xFF, 0x00, 0xD0, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
67 [ 'crc-8-wcdma', 'Crc8Wcdma', 0x19B, REVERSE, 0x00, 0x00, 0x25, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
68
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
69 [ 'crc-16', 'Crc16', 0x18005, REVERSE, 0x0000, 0x0000, 0xBB3D, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
70 [ 'crc-16-buypass', 'Crc16Buypass', 0x18005, NON_REVERSE, 0x0000, 0x0000, 0xFEE8, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
71 [ 'crc-16-dds-110', 'Crc16Dds110', 0x18005, NON_REVERSE, 0x800D, 0x0000, 0x9ECF, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
72 [ 'crc-16-dect', 'Crc16Dect', 0x10589, NON_REVERSE, 0x0001, 0x0001, 0x007E, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
73 [ 'crc-16-dnp', 'Crc16Dnp', 0x13D65, REVERSE, 0xFFFF, 0xFFFF, 0xEA82, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
74 [ 'crc-16-en-13757', 'Crc16En13757', 0x13D65, NON_REVERSE, 0xFFFF, 0xFFFF, 0xC2B7, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
75 [ 'crc-16-genibus', 'Crc16Genibus', 0x11021, NON_REVERSE, 0x0000, 0xFFFF, 0xD64E, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
76 [ 'crc-16-maxim', 'Crc16Maxim', 0x18005, REVERSE, 0xFFFF, 0xFFFF, 0x44C2, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
77 [ 'crc-16-mcrf4xx', 'Crc16Mcrf4xx', 0x11021, REVERSE, 0xFFFF, 0x0000, 0x6F91, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
78 [ 'crc-16-riello', 'Crc16Riello', 0x11021, REVERSE, 0x554D, 0x0000, 0x63D0, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
79 [ 'crc-16-t10-dif', 'Crc16T10Dif', 0x18BB7, NON_REVERSE, 0x0000, 0x0000, 0xD0DB, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
80 [ 'crc-16-teledisk', 'Crc16Teledisk', 0x1A097, NON_REVERSE, 0x0000, 0x0000, 0x0FB3, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
81 [ 'crc-16-usb', 'Crc16Usb', 0x18005, REVERSE, 0x0000, 0xFFFF, 0xB4C8, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
82 [ 'x-25', 'CrcX25', 0x11021, REVERSE, 0x0000, 0xFFFF, 0x906E, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
83 [ 'xmodem', 'CrcXmodem', 0x11021, NON_REVERSE, 0x0000, 0x0000, 0x31C3, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
84 [ 'modbus', 'CrcModbus', 0x18005, REVERSE, 0xFFFF, 0x0000, 0x4B37, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
85
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
86 # Note definitions of CCITT are disputable. See:
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
87 # http://homepages.tesco.net/~rainstorm/crc-catalogue.htm
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
88 # http://web.archive.org/web/20071229021252/http://www.joegeluso.com/software/articles/ccitt.htm
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
89 [ 'kermit', 'CrcKermit', 0x11021, REVERSE, 0x0000, 0x0000, 0x2189, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
90 [ 'crc-ccitt-false', 'CrcCcittFalse', 0x11021, NON_REVERSE, 0xFFFF, 0x0000, 0x29B1, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
91 [ 'crc-aug-ccitt', 'CrcAugCcitt', 0x11021, NON_REVERSE, 0x1D0F, 0x0000, 0xE5CC, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
92
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
93 [ 'crc-24', 'Crc24', 0x1864CFB, NON_REVERSE, 0xB704CE, 0x000000, 0x21CF02, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
94 [ 'crc-24-flexray-a', 'Crc24FlexrayA', 0x15D6DCB, NON_REVERSE, 0xFEDCBA, 0x000000, 0x7979BD, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
95 [ 'crc-24-flexray-b', 'Crc24FlexrayB', 0x15D6DCB, NON_REVERSE, 0xABCDEF, 0x000000, 0x1F23B8, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
96
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
97 [ 'crc-32', 'Crc32', 0x104C11DB7, REVERSE, 0x00000000, 0xFFFFFFFF, 0xCBF43926, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
98 [ 'crc-32-bzip2', 'Crc32Bzip2', 0x104C11DB7, NON_REVERSE, 0x00000000, 0xFFFFFFFF, 0xFC891918, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
99 [ 'crc-32c', 'Crc32C', 0x11EDC6F41, REVERSE, 0x00000000, 0xFFFFFFFF, 0xE3069283, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
100 [ 'crc-32d', 'Crc32D', 0x1A833982B, REVERSE, 0x00000000, 0xFFFFFFFF, 0x87315576, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
101 [ 'crc-32-mpeg', 'Crc32Mpeg', 0x104C11DB7, NON_REVERSE, 0xFFFFFFFF, 0x00000000, 0x0376E6E7, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
102 [ 'posix', 'CrcPosix', 0x104C11DB7, NON_REVERSE, 0xFFFFFFFF, 0xFFFFFFFF, 0x765E7680, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
103 [ 'crc-32q', 'Crc32Q', 0x1814141AB, NON_REVERSE, 0x00000000, 0x00000000, 0x3010BF7F, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
104 [ 'jamcrc', 'CrcJamCrc', 0x104C11DB7, REVERSE, 0xFFFFFFFF, 0x00000000, 0x340BC6D9, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
105 [ 'xfer', 'CrcXfer', 0x1000000AF, NON_REVERSE, 0x00000000, 0x00000000, 0xBD0BE338, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
106
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
107 # 64-bit
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
108 # Name Identifier-name, Poly Reverse Init-value XOR-out Check
182
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
109 [ 'crc-64', 'Crc64', 0x1000000000000001B, REVERSE, 0x0000000000000000, 0x0000000000000000, 0x46A5A9388A5BEFFE, ], # ISO POLY
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
110 # See https://lwn.net/Articles/976030/ (MCRC64, used as CRC-64 in the Linux kernel)
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
111 [ 'crc-64-2', 'Crc64_2', 0x1000000000000001B, NON_REVERSE, 0x0000000000000000, 0x0000000000000000, 0xE4FFBEA588933790, ], # fag, ISO POLY
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
112 [ 'crc-64-go', 'Crc64Go', 0x1000000000000001B, REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0xB90956C775A41001, ], # fag, ISO POLY
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
113 [ 'crc-64-ecma', 'Crc64Ecma', 0x142F0E1EBA9EA3693, NON_REVERSE, 0x0000000000000000, 0x0000000000000000, 0x6C40DF5F0B497347, ], # fag
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
114 [ 'crc-64-we', 'Crc64We', 0x142F0E1EBA9EA3693, NON_REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0x62EC59E3F1A4F00A, ],
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
115 [ 'crc-64-jones', 'Crc64Jones', 0x1AD93D23594C935A9, REVERSE, 0xFFFFFFFFFFFFFFFF, 0x0000000000000000, 0xCAA717168609F281, ],
182
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
116 [ 'crc-64-xz', 'Crc64Xz', 0x142F0E1EBA9EA3693, REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0x995DC9BBDF1939FA, ], # fag, ECMA POLY
31d478ff4e09 Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents: 180
diff changeset
117 [ 'crc-64-redis', 'Crc64Redis', 0x1AD93D23594C935A9, REVERSE, 0x0000000000000000, 0x0000000000000000, 0xE9C6D914C4b8D9CA, ], # fag
180
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
118 ]
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
119
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
120
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
121 def _simplify_name(name):
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
122 """
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
123 Reduce CRC definition name to a simplified form:
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
124 * lowercase
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
125 * dashes removed
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
126 * spaces removed
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
127 * any initial "CRC" string removed
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
128 """
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
129 name = name.lower()
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
130 name = name.replace('-', '')
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
131 name = name.replace(' ', '')
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
132 if name.startswith('crc'):
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
133 name = name[len('crc'):]
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
134 return name
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
135
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
136
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
137 _crc_definitions_by_name = {}
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
138 _crc_definitions_by_identifier = {}
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
139 _crc_definitions = []
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
140
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
141 _crc_table_headings = [ 'name', 'identifier', 'poly', 'reverse', 'init', 'xor_out', 'check' ]
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
142
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
143 for table_entry in _crc_definitions_table:
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
144 crc_definition = dict(zip(_crc_table_headings, table_entry))
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
145 _crc_definitions.append(crc_definition)
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
146 name = _simplify_name(table_entry[0])
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
147 if name in _crc_definitions_by_name:
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
148 raise Exception("Duplicate entry for '{0}' in CRC table".format(name))
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
149 _crc_definitions_by_name[name] = crc_definition
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
150 _crc_definitions_by_identifier[table_entry[1]] = crc_definition
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
151
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
152
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
153 def _get_definition_by_name(crc_name):
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
154 definition = _crc_definitions_by_name.get(_simplify_name(crc_name), None)
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
155 if not definition:
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
156 definition = _crc_definitions_by_identifier.get(crc_name, None)
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
157 if not definition:
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
158 raise KeyError("Unkown CRC name '{0}'".format(crc_name))
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
159 return definition
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
160
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
161
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
162 class PredefinedCrc(crcmod.Crc):
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
163 def __init__(self, crc_name):
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
164 definition = _get_definition_by_name(crc_name)
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
165 super().__init__(poly=definition['poly'], initCrc=definition['init'], rev=definition['reverse'], xorOut=definition['xor_out'])
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
166
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
167
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
168 # crcmod.predefined.Crc is an alias for crcmod.predefined.PredefinedCrc
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
169 Crc = PredefinedCrc
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
170
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
171
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
172 def mkPredefinedCrcFun(crc_name):
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
173 definition = _get_definition_by_name(crc_name)
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
174 return crcmod.mkCrcFun(poly=definition['poly'], initCrc=definition['init'], rev=definition['reverse'], xorOut=definition['xor_out'])
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
175
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
176
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
177 # crcmod.predefined.mkCrcFun is an alias for crcmod.predefined.mkPredefinedCrcFun
d038f0a9ba49 Vendored crcmod2 into sub-package "cutils.crcmod" as pure-Python implementation of additional "digests": CRC sums.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
178 mkCrcFun = mkPredefinedCrcFun