I know decryption is an expansive world which I'm a novice in, but I have a WinZip file I can open in WinZip with the known password easily through the WinZip UI.
However, supplying the same password, I cannot open it in Python. I suspect the encoding is possibly in AES, but I don't want to involve a non-native library to open the file. Is there any standard to open password protected WinZip files in Python? I've tried the different codec's of encoding in ZipFile.
from zipfile import ZipFile
with ZipFile(r'C:\Users\user\Desktop\Data.zip') as zf:
pas = 'myPass'
res = pas.encode('utf-32-le')
zf.extractall(pwd=res)
zf
RuntimeError: Bad password for file ...
You first need to determine what type of encryption the zip file is using. There may be a reporting tool in WinZip itself that will tell you. I don't have it, so don't know.
If you have access to any of the command line zip utilities you can find out quite easily.
Firstly if you have the Infozip implementation of
unzipavailable, run it with the-lvoption. If you have a very new version ofunzipavailable and it displaysAES_WGin the Method column, your file is AES encrypted.If your
unzipis older, the presence of the stringUnk:099in the Method column means your file is AES encrypted (but the version of unzip you have doesn't support unzipping it).Another alternative is to use zipdetails (full disclosure, I'm the author of zipdetails). The key thing to look for is the line
Compression Method 0063 'AES Encryption'If it turns out you do have AES encryption and you need a python way to read the file, the standard
zipfileapproach will not work. As things standzipfileonly supports weak encryption.For other python ways to read AES-encrypted Zip files see Python unzip AES-128 encrypted file