def crc32(self):
"""
A little bit old-fashioned, but some encodings like yEnc require that
a crc32 value be used. This calculates it based on the file
"""
# block size defined as 2**16
block_size = 65536
# The mask to apply to all CRC checking
BIN_MASK = 0xffffffffL
# Initialize
_crc = 0
if self.open(mode=NNTPFileMode.BINARY_RO):
for chunk in iter(lambda: self.stream.read(block_size), b''):
_crc = crc32(chunk, _crc)
return format(_crc & BIN_MASK, '08x')
return None
评论列表
文章目录