Python中的zlib.crc32()
借助zlib.crc32()
方法,我们可以计算 crc32(循环冗余校验)对特定数据的校验和。它将通过使用zlib.crc32()
方法给出 32 位整数值作为结果。
Syntax : zlib.crc32(s)
Return : Return the unsigned 32-bit checksum integer.
示例 #1:
在这个例子中,我们可以看到通过使用zlib.crc32()
方法,我们能够使用这个方法计算给定数据的无符号 32 位校验和。
# import zlib and crc32
import zlib
s = b'I love python, Hello world'
# using zlib.crc32() method
t = zlib.crc32(s)
print(t)
输出 :
2185029202
示例 #2:
# import zlib and crc32
import zlib
s = b'Hello GeeksForGeeks'
# using zlib.crc32() method
t = zlib.crc32(s)
print(t)
输出 :
3165518624