Python's zipfile library can't extract password protected file

533 views Asked by At

For some reason, Python's zipfile library cannot extract the files in this password-protected zipfile archive. Here is the code I used:

import zipfile

zip_filename = 'extract_public_2018_20201006094007483_71129_20201001-20201006Texas.zip'

zipfile_password = b'&CkN52mKji3R8^4aI#7Z'

with zipfile.ZipFile(zip_filename) as myzip:
    myzip.extractall(pwd=zipfile_password)

This is the error I get: NotImplementedError: That compression method is not supported

I dug a little deeper and found that the compression method for the files inside this archive is 99. Where can I find what this compression method really is? And does this just mean I can't unzip this file using Python's zipfile librabry?

I'm using Python 3.8.

1

There are 1 answers

1
Mark Adler On BEST ANSWER

PKWare's appnote says that 99 is:

99 - AE-x encryption marker (see APPENDIX E)

...

APPENDIX E - AE-x encryption marker


E.1 AE-x defines an alternate password-based encryption method used in ZIP files that is based on a file encryption utility developed by Dr. Brian Gladman. Information on Dr. Gladman's method is available at

http://www.gladman.me.uk/cryptography_technology/fileencrypt/

I'm guessing there are no libraries to help with that. You're probably stuck using 7z or PKZIP.