(pwd)
| 711 | # plain_bytes = zd(cypher_bytes) |
| 712 | |
| 713 | def _ZipDecrypter(pwd): |
| 714 | key0 = 305419896 |
| 715 | key1 = 591751049 |
| 716 | key2 = 878082192 |
| 717 | |
| 718 | global _crctable |
| 719 | if _crctable is None: |
| 720 | _crctable = list(map(_gen_crc, range(256))) |
| 721 | crctable = _crctable |
| 722 | |
| 723 | def crc32(ch, crc): |
| 724 | """Compute the CRC32 primitive on one byte.""" |
| 725 | return (crc >> 8) ^ crctable[(crc ^ ch) & 0xFF] |
| 726 | |
| 727 | def update_keys(c): |
| 728 | nonlocal key0, key1, key2 |
| 729 | key0 = crc32(c, key0) |
| 730 | key1 = (key1 + (key0 & 0xFF)) & 0xFFFFFFFF |
| 731 | key1 = (key1 * 134775813 + 1) & 0xFFFFFFFF |
| 732 | key2 = crc32(key1 >> 24, key2) |
| 733 | |
| 734 | for p in pwd: |
| 735 | update_keys(p) |
| 736 | |
| 737 | def decrypter(data): |
| 738 | """Decrypt a bytes object.""" |
| 739 | result = bytearray() |
| 740 | append = result.append |
| 741 | for c in data: |
| 742 | k = key2 | 2 |
| 743 | c ^= ((k * (k^1)) >> 8) & 0xFF |
| 744 | update_keys(c) |
| 745 | append(c) |
| 746 | return bytes(result) |
| 747 | |
| 748 | return decrypter |
| 749 | |
| 750 | |
| 751 | class LZMACompressor: |
no test coverage detected
searching dependent graphs…