(pwd)
| 592 | # plain_bytes = zd(cypher_bytes) |
| 593 | |
| 594 | def _ZipDecrypter(pwd): |
| 595 | key0 = 305419896 |
| 596 | key1 = 591751049 |
| 597 | key2 = 878082192 |
| 598 | |
| 599 | global _crctable |
| 600 | if _crctable is None: |
| 601 | _crctable = list(map(_gen_crc, range(256))) |
| 602 | crctable = _crctable |
| 603 | |
| 604 | def crc32(ch, crc): |
| 605 | """Compute the CRC32 primitive on one byte.""" |
| 606 | return (crc >> 8) ^ crctable[(crc ^ ch) & 0xFF] |
| 607 | |
| 608 | def update_keys(c): |
| 609 | nonlocal key0, key1, key2 |
| 610 | key0 = crc32(c, key0) |
| 611 | key1 = (key1 + (key0 & 0xFF)) & 0xFFFFFFFF |
| 612 | key1 = (key1 * 134775813 + 1) & 0xFFFFFFFF |
| 613 | key2 = crc32(key1 >> 24, key2) |
| 614 | |
| 615 | for p in pwd: |
| 616 | update_keys(p) |
| 617 | |
| 618 | def decrypter(data): |
| 619 | """Decrypt a bytes object.""" |
| 620 | result = bytearray() |
| 621 | append = result.append |
| 622 | for c in data: |
| 623 | k = key2 | 2 |
| 624 | c ^= ((k * (k^1)) >> 8) & 0xFF |
| 625 | update_keys(c) |
| 626 | append(c) |
| 627 | return bytes(result) |
| 628 | |
| 629 | return decrypter |
| 630 | |
| 631 | |
| 632 | class LZMACompressor: |
no test coverage detected