Mercurial > hgrepos > Python > apps > py-cutils
annotate cutils/crcmod/python2/predefined.py @ 242:ae9bc3006efc
Enhanced help message: describe the "bin-" prefix
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 08 Feb 2025 09:47:34 +0100 |
| parents | 5c5c0c5a7402 |
| children |
| 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 from __future__ import absolute_import |
|
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 |
|
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 # 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
|
39 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
|
40 |
|
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 __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
|
42 '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
|
43 '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
|
44 ] |
|
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 |
|
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 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
|
47 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
|
48 |
|
182
31d478ff4e09
Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents:
180
diff
changeset
|
49 # |
|
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
|
50 # 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
|
51 # The "Check" value is the CRC for the ASCII byte sequence "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
|
52 # 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
|
53 # |
|
31d478ff4e09
Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents:
180
diff
changeset
|
54 # See also: |
|
31d478ff4e09
Syced with latest additions to crcmod2: new predefined CRC-64 models
Franz Glasner <fzglas.hg@dom66.de>
parents:
180
diff
changeset
|
55 # - 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
|
56 # - 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
|
57 # - 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
|
58 # - 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
|
59 # - 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
|
60 # |
|
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
|
61 _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
|
62 # 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
|
63 [ '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
|
64 [ '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
|
65 [ '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
|
66 [ '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
|
67 [ '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
|
68 [ '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
|
69 [ '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
|
70 |
|
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', '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
|
72 [ '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
|
73 [ '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
|
74 [ '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
|
75 [ '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
|
76 [ '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
|
77 [ '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
|
78 [ '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
|
79 [ '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
|
80 [ '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
|
81 [ '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
|
82 [ '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
|
83 [ '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
|
84 [ '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
|
85 [ '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
|
86 [ '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
|
87 |
|
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 # 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
|
89 # 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
|
90 # 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
|
91 [ '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
|
92 [ '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
|
93 [ '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
|
94 |
|
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', '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
|
96 [ '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
|
97 [ '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
|
98 |
|
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-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
|
100 [ '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
|
101 [ '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
|
102 [ '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
|
103 [ '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
|
104 [ '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
|
105 [ '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
|
106 [ '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
|
107 [ '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
|
108 |
|
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
|
109 # 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
|
110 # 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
|
111 [ '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
|
112 # 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
|
113 [ '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
|
114 [ '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
|
115 [ '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
|
116 [ '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
|
117 [ '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
|
118 [ '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
|
119 [ '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
|
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 |
|
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 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
|
124 """ |
|
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 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
|
126 * 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
|
127 * 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
|
128 * 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
|
129 * 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
|
130 """ |
|
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.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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 |
|
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 |
|
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_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
|
140 _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
|
141 _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
|
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 _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
|
144 |
|
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 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
|
146 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
|
147 _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
|
148 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
|
149 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
|
150 raise Exception("Duplicate entry for '%s' in CRC table" % 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
|
151 _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
|
152 _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
|
153 |
|
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 |
|
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 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
|
156 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
|
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 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
|
159 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
|
160 raise KeyError("Unkown CRC name '%s'" % 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
|
161 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
|
162 |
|
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 |
|
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 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
|
165 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
|
166 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
|
167 crcmod.Crc.__init__(self, 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
|
168 |
|
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 |
|
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 # 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
|
171 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
|
172 |
|
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 |
|
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 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
|
175 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
|
176 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
|
177 |
|
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 |
|
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
|
179 # 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
|
180 mkCrcFun = mkPredefinedCrcFun |
