# HG changeset patch # User Daniel Holth # Date 1374330889 14400 # Node ID fe1516603ce99486427ffcc79e3552bd7739e75a # Parent e7305517260bdcb457ef6769587f97ea3a8c5d1d remove zipfile._ZipDecryptor._GenerateCRCTable() diff -r e7305517260b -r fe1516603ce9 Lib/zipfile.py --- a/Lib/zipfile.py Sat Jul 20 15:12:19 2013 +0200 +++ b/Lib/zipfile.py Sat Jul 20 10:34:49 2013 -0400 @@ -457,29 +457,9 @@ plain_text = map(zd, cypher_text) """ - def _GenerateCRCTable(): - """Generate a CRC-32 table. - - ZIP encryption uses the CRC32 one-byte primitive for scrambling some - internal keys. We noticed that a direct implementation is faster than - relying on binascii.crc32(). - """ - poly = 0xedb88320 - table = [0] * 256 - for i in range(256): - crc = i - for j in range(8): - if crc & 1: - crc = ((crc >> 1) & 0x7FFFFFFF) ^ poly - else: - crc = ((crc >> 1) & 0x7FFFFFFF) - table[i] = crc - return table - crctable = _GenerateCRCTable() - def _crc32(self, ch, crc): """Compute the CRC32 primitive on one byte.""" - return ((crc >> 8) & 0xffffff) ^ self.crctable[(crc ^ ch) & 0xff] + return crc32(ch, crc) & 0xffffffff def __init__(self, pwd): self.key0 = 305419896