Closed vadmium closed 7 years ago
If I had known this it would have saved me getting a separate implementation working.
>>> hex(binascii.crc_hqx(b"\x01", 0))
'0x1021'
https://files.stairways.com/other/binhex-40-specs-info.txt
Documenting this might helped many other people. Top Google hits seem oblivious to crc_hqx(), using other CRC implementations, and even other helper functions from the binascii module:
https://pypi.python.org/pypi/crc16 http://stackoverflow.com/questions/26204060/calculate-crc-ccitt-0xffff-for-hex-string
If document the polynomial for crc_hqx, maybe document it for crc32 and adler32?
Wouldn't be better to write the formula as *x\ :sup:`16` + *x\ :sup:`12 + *x*\ :sup:`5` + 1 ?
It seems I can write it without the escaped spaces. Is there a problem with this:
*x:sup:`16` + *x:sup:`12` + *x*:sup:`5` + 1
I’m happy to add the CRC-32 polynomial if you think it would be useful, although it is a lot longer (fifteen terms instead of four). And this CRC is already easily identified by the CRC-32 name. As well as the polynomial, there are other details that identify a CRC. The bits in CRC-32 are reversed and inverted compared to CRC-CCITT.
>>> hex(crc32(b"\x80", 0xFFFFFFFF) ^ 0xFFFFFFFF)
'0xedb88320'
# 0xEDB88320 is the reversed polynomial representation; the x^0 term corresponds to bit 31
Adler32 is not a CRC, and I don’t think there are multiple versions of the algorithm, so I don’t think it would need any special explanation.
Okay, then the patch LGTM. Use the form of the polynomial that you prefer.
New changeset a33472f8a2c6 by Martin Panter in branch '3.5': Issue bpo-29004: Document binascii.crc_hqx() implements CRC-CCITT https://hg.python.org/cpython/rev/a33472f8a2c6
New changeset 52db2072e88b by Martin Panter in branch '3.6': Issue bpo-29004: Merge crc_hqx() doc from 3.5 https://hg.python.org/cpython/rev/52db2072e88b
New changeset 3af3702b2f0a by Martin Panter in branch 'default': Issue bpo-29004: Merge crc_hqx() doc from 3.6 https://hg.python.org/cpython/rev/3af3702b2f0a
New changeset 5ae6102270df by Martin Panter in branch '2.7': Issue bpo-29004: Document binascii.crc_hqx() implements CRC-CCITT https://hg.python.org/cpython/rev/5ae6102270df
Thanks for the help Serhiy
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at =
created_at =
labels = ['3.7', 'docs']
title = 'binascii.crc_hqx() implements CRC-CCITT'
updated_at =
user = 'https://github.com/vadmium'
```
bugs.python.org fields:
```python
activity =
actor = 'martin.panter'
assignee = 'docs@python'
closed = True
closed_date =
closer = 'martin.panter'
components = ['Documentation']
creation =
creator = 'martin.panter'
dependencies = []
files = ['45952']
hgrepos = []
issue_num = 29004
keywords = ['patch']
message_count = 6.0
messages = ['283548', '283550', '283552', '283553', '283925', '283933']
nosy_count = 8.0
nosy_names = ['lemburg', 'mark.dickinson', 'eric.smith', 'stutzbach', 'docs@python', 'python-dev', 'martin.panter', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue29004'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7']
```