Mercurial > hgrepos > Python > apps > py-cutils
changeset 182:31d478ff4e09
Syced with latest additions to crcmod2: new predefined CRC-64 models
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 13 Jan 2025 15:52:26 +0100 |
| parents | c4f737ec368c |
| children | 62436c255dc8 |
| files | cutils/crcmod/python2/predefined.py cutils/crcmod/python3/predefined.py |
| diffstat | 2 files changed, 38 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/cutils/crcmod/python2/predefined.py Mon Jan 13 04:15:08 2025 +0100 +++ b/cutils/crcmod/python2/predefined.py Mon Jan 13 15:52:26 2025 +0100 @@ -7,10 +7,10 @@ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -24,7 +24,7 @@ To use it, e.g.: import crcmod.predefined - + crc32func = crcmod.predefined.mkPredefinedCrcFun("crc-32") crc32class = crcmod.predefined.PredefinedCrc("crc-32") @@ -45,9 +45,18 @@ REVERSE = True NON_REVERSE = False +# # The following table defines the parameters of well-known CRC algorithms. # The "Check" value is the CRC for the ASCII byte sequence "123456789". It # can be used for unit tests. +# +# See also: +# - https://en.wikipedia.org/wiki/Cyclic_redundancy_check +# - https://reveng.sourceforge.io/crc-catalogue/all.htm +# - http://users.ece.cmu.edu/~koopman/crc/index.html +# - https://pycrc.org/models.html +# - https://github.com/marzooqy/anycrc +# _crc_definitions_table = [ # Name Identifier-name, Poly Reverse Init-value XOR-out Check [ 'crc-8', 'Crc8', 0x107, NON_REVERSE, 0x00, 0x00, 0xF4, ], @@ -98,9 +107,15 @@ # 64-bit # Name Identifier-name, Poly Reverse Init-value XOR-out Check - [ 'crc-64', 'Crc64', 0x1000000000000001B, REVERSE, 0x0000000000000000, 0x0000000000000000, 0x46A5A9388A5BEFFE, ], + [ 'crc-64', 'Crc64', 0x1000000000000001B, REVERSE, 0x0000000000000000, 0x0000000000000000, 0x46A5A9388A5BEFFE, ], # ISO POLY + # See https://lwn.net/Articles/976030/ (MCRC64, used as CRC-64 in the Linux kernel) + [ 'crc-64-2', 'Crc64_2', 0x1000000000000001B, NON_REVERSE, 0x0000000000000000, 0x0000000000000000, 0xE4FFBEA588933790, ], # fag, ISO POLY + [ 'crc-64-go', 'Crc64Go', 0x1000000000000001B, REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0xB90956C775A41001, ], # fag, ISO POLY + [ 'crc-64-ecma', 'Crc64Ecma', 0x142F0E1EBA9EA3693, NON_REVERSE, 0x0000000000000000, 0x0000000000000000, 0x6C40DF5F0B497347, ], # fag [ 'crc-64-we', 'Crc64We', 0x142F0E1EBA9EA3693, NON_REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0x62EC59E3F1A4F00A, ], [ 'crc-64-jones', 'Crc64Jones', 0x1AD93D23594C935A9, REVERSE, 0xFFFFFFFFFFFFFFFF, 0x0000000000000000, 0xCAA717168609F281, ], + [ 'crc-64-xz', 'Crc64Xz', 0x142F0E1EBA9EA3693, REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0x995DC9BBDF1939FA, ], # fag, ECMA POLY + [ 'crc-64-redis', 'Crc64Redis', 0x1AD93D23594C935A9, REVERSE, 0x0000000000000000, 0x0000000000000000, 0xE9C6D914C4b8D9CA, ], # fag ]
--- a/cutils/crcmod/python3/predefined.py Mon Jan 13 04:15:08 2025 +0100 +++ b/cutils/crcmod/python3/predefined.py Mon Jan 13 15:52:26 2025 +0100 @@ -7,10 +7,10 @@ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -24,7 +24,7 @@ To use it, e.g.: import crcmod.predefined - + crc32func = crcmod.predefined.mkPredefinedCrcFun("crc-32") crc32class = crcmod.predefined.PredefinedCrc("crc-32") @@ -43,9 +43,18 @@ REVERSE = True NON_REVERSE = False +# # The following table defines the parameters of well-known CRC algorithms. # The "Check" value is the CRC for the ASCII byte sequence b"123456789". It # can be used for unit tests. +# +# See also: +# - https://en.wikipedia.org/wiki/Cyclic_redundancy_check +# - https://reveng.sourceforge.io/crc-catalogue/all.htm +# - http://users.ece.cmu.edu/~koopman/crc/index.html +# - https://pycrc.org/models.html +# - https://github.com/marzooqy/anycrc +# _crc_definitions_table = [ # Name Identifier-name, Poly Reverse Init-value XOR-out Check [ 'crc-8', 'Crc8', 0x107, NON_REVERSE, 0x00, 0x00, 0xF4, ], @@ -96,9 +105,15 @@ # 64-bit # Name Identifier-name, Poly Reverse Init-value XOR-out Check - [ 'crc-64', 'Crc64', 0x1000000000000001B, REVERSE, 0x0000000000000000, 0x0000000000000000, 0x46A5A9388A5BEFFE, ], + [ 'crc-64', 'Crc64', 0x1000000000000001B, REVERSE, 0x0000000000000000, 0x0000000000000000, 0x46A5A9388A5BEFFE, ], # ISO POLY + # See https://lwn.net/Articles/976030/ (MCRC64, used as CRC-64 in the Linux kernel) + [ 'crc-64-2', 'Crc64_2', 0x1000000000000001B, NON_REVERSE, 0x0000000000000000, 0x0000000000000000, 0xE4FFBEA588933790, ], # fag, ISO POLY + [ 'crc-64-go', 'Crc64Go', 0x1000000000000001B, REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0xB90956C775A41001, ], # fag, ISO POLY + [ 'crc-64-ecma', 'Crc64Ecma', 0x142F0E1EBA9EA3693, NON_REVERSE, 0x0000000000000000, 0x0000000000000000, 0x6C40DF5F0B497347, ], # fag [ 'crc-64-we', 'Crc64We', 0x142F0E1EBA9EA3693, NON_REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0x62EC59E3F1A4F00A, ], [ 'crc-64-jones', 'Crc64Jones', 0x1AD93D23594C935A9, REVERSE, 0xFFFFFFFFFFFFFFFF, 0x0000000000000000, 0xCAA717168609F281, ], + [ 'crc-64-xz', 'Crc64Xz', 0x142F0E1EBA9EA3693, REVERSE, 0x0000000000000000, 0xFFFFFFFFFFFFFFFF, 0x995DC9BBDF1939FA, ], # fag, ECMA POLY + [ 'crc-64-redis', 'Crc64Redis', 0x1AD93D23594C935A9, REVERSE, 0x0000000000000000, 0x0000000000000000, 0xE9C6D914C4b8D9CA, ], # fag ]
