[Tutor] Extracting from password protected zipfiles

Norvell Spearman norvell@houseofspearman.org
Thu May 15 04:30:01 2003

On Thursday, 2003.05.15, 09:47:23 +0200, Charlie Clark wrote:
> Dear list,
> I've received a bundle of fotos in a zip file from a friend but the file is 
> password protected and neither unzip (5.40) nor gzip(1.2.4) support 
> decryption on my system so I thought I would try Python's own zipfile 
> module. Unfortunately that doesn't seem to work either. Searching the net 
> hasn't revealed much either.
> As I get an error on attempting to read the data, I guess it's not possible 
> to read and decrypt but I have to pass the password in some form. Any ideas 
> as to whether this possible?

The version of unzip on my system (v. 5.41) has a `-P' option where you
can specify a password; the man page warns that using this option isn't

If the zipfile module doesn't accept passwords when opening a zipped
file, then could you use an os.exec*() call and include the password as
an argument to unzip?

Norvell Spearman