'Getting error 'NotImplementedError("That compression method is not supported")' when extracting zipfile in python3.9
I have read through the Python documentation about zip files and watched a couple of videos, but everything didn't work. I'm using Kali Linux, so that the password has to be encoded in bytes.
Here is my code, with which I have tried:
import zipfile
import string
import traceback
def try_function(zip, pwd):
    try:
        zip.extractall(pwd=pwd.encode())
        print("Yes")
    except TypeError:
        print("No")
z = zipfile.ZipFile("test.txt.zip")
pwd_local = "abc"
if __name__ == '__main__':
    try_function(z, pwd_local)
But I always get the same error:
Traceback (most recent call last):
  File "ZipWorker.py", line 22, in <module>
    try_function(z, pwd_list)
  File "ZipWorker.py", line 11, in crack
    zip.extractall(pwd.encode())
  File "/usr/lib/python3.9/zipfile.py", line 1633, in extractall
    self._extract_member(zipinfo, path, pwd)
  File "/usr/lib/python3.9/zipfile.py", line 1686, in _ 
extract_member
    with self.open(member, pwd=pwd) as source, \
  File "/usr/lib/python3.9/zipfile.py", line 1559, in open
    return ZipExtFile(zef_file, mode, zinfo, pwd, True)
  File "/usr/lib/python3.9/zipfile.py", line 797, in __init__
    self._decompressor = _get_decompressor(self._compress_type)
  File "/usr/lib/python3.9/zipfile.py", line 698, in 
_get_decompressor
    _check_compression(compress_type)
  File "/usr/lib/python3.9/zipfile.py", line 678, in 
_check_compression
    raise NotImplementedError("That compression method is not 
supported")
  NotImplementedError: That compression method is not supported
Does anyone know how to do this? I'm using python3.9.
Solution 1:[1]
So I finally find out, why the code above doesn't work. 
When you are creating a zipfile with for example 7zip, this zip file will be encrypted.
But the encryption isn't in bytes, it's encrypted in the hashes: AES-256 or ZipCrypto.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | 
