用法:
binascii.crc32(data[, value])
計算 CRC-32,即
data
的 32 位校驗和,從value
的初始 CRC 開始。默認初始 CRC 為零。該算法與 ZIP 文件校驗和一致。由於該算法是為用作校驗和算法而設計的,因此不適合用作一般的哈希算法。使用如下:print(binascii.crc32(b"hello world")) # Or, in two pieces: crc = binascii.crc32(b"hello") crc = binascii.crc32(b" world", crc) print('crc32 = {:#010x}'.format(crc))
在 3.0 版中更改:結果總是無符號的。要在所有 Python 版本和平台上生成相同的數值,請使用
crc32(data) & 0xffffffff
.
相關用法
- Python binascii.b2a_hex用法及代碼示例
- Python binary轉string用法及代碼示例
- Python binary轉ASCII用法及代碼示例
- Python bin用法及代碼示例
- Python bin()用法及代碼示例
- Python bytes.isupper用法及代碼示例
- Python base64.b64decode()用法及代碼示例
- Python bokeh.plotting.figure.asterisk()用法及代碼示例
- Python bytes.zfill用法及代碼示例
- Python base64.b32decode()用法及代碼示例
- Python bytearray()用法及代碼示例
- Python bokeh.plotting.figure.annular_wedge()用法及代碼示例
- Python bool()用法及代碼示例
- Python bytes.isalpha用法及代碼示例
- Python base64.b85encode()用法及代碼示例
- Python bokeh.plotting.figure.circle()用法及代碼示例
- Python bytes.hex用法及代碼示例
- Python bz2.decompress(s)用法及代碼示例
- Python bokeh.plotting.figure.circle_cross()用法及代碼示例
- Python bokeh.plotting.figure.bezier()用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 binascii.crc32。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。