summaryrefslogtreecommitdiffstats
path: root/Doc/library/binascii.rst
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-12-11 05:41:48 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-12-11 05:41:48 (GMT)
commit70fe09bc67098756349c1dc35e0d8d85a4c465cf (patch)
tree5f7d39b1137ceb3ed2bb3584ec283d2f73fe673d /Doc/library/binascii.rst
parent8c0b5b998ae3319294a366cfb0bdad9fc88ff1fc (diff)
parentb82032f935962d13220bba52d26ac607149485eb (diff)
downloadcpython-70fe09bc67098756349c1dc35e0d8d85a4c465cf.zip
cpython-70fe09bc67098756349c1dc35e0d8d85a4c465cf.tar.gz
cpython-70fe09bc67098756349c1dc35e0d8d85a4c465cf.tar.bz2
Issue #22341: Merge CRC doc from 3.5
Diffstat (limited to 'Doc/library/binascii.rst')
-rw-r--r--Doc/library/binascii.rst23
1 files changed, 11 insertions, 12 deletions
diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst
index 441aa57..0cd18b1 100644
--- a/Doc/library/binascii.rst
+++ b/Doc/library/binascii.rst
@@ -115,15 +115,16 @@ The :mod:`binascii` module defines the following functions:
possibly the last fragment).
-.. function:: crc_hqx(data, crc)
+.. function:: crc_hqx(data, value)
- Compute the binhex4 crc value of *data*, starting with an initial *crc* and
- returning the result.
+ Compute the binhex4 crc value of *data*, starting with *value* as the
+ initial crc, and return the result.
-.. function:: crc32(data[, crc])
+.. function:: crc32(data[, value])
- Compute CRC-32, the 32-bit checksum of data, starting with an initial crc. This
+ Compute CRC-32, the 32-bit checksum of *data*, starting with an
+ initial CRC of *value*. The default initial CRC is zero. The algorithm
is consistent with the ZIP file checksum. Since the algorithm is designed for
use as a checksum algorithm, it is not suitable for use as a general hash
algorithm. Use as follows::
@@ -131,15 +132,13 @@ The :mod:`binascii` module defines the following functions:
print(binascii.crc32(b"hello world"))
# Or, in two pieces:
crc = binascii.crc32(b"hello")
- crc = binascii.crc32(b" world", crc) & 0xffffffff
+ crc = binascii.crc32(b" world", crc)
print('crc32 = {:#010x}'.format(crc))
-.. note::
- To generate the same numeric value across all Python versions and
- platforms use crc32(data) & 0xffffffff. If you are only using
- the checksum in packed binary format this is not necessary as the
- return value is the correct 32bit binary representation
- regardless of sign.
+ .. versionchanged:: 3.0
+ The result is always unsigned.
+ To generate the same numeric value across all Python versions and
+ platforms, use ``crc32(data) & 0xffffffff``.
.. function:: b2a_hex(data)