smihica / pyminizip

To create a password encrypted zip file in python.
Other
106 stars 37 forks source link

encryption does not work with compress_multiple #5

Closed ppawiggers closed 9 years ago

ppawiggers commented 9 years ago

This works fine (it creates a password protected ZIP):

pyminizip.compress('file1.docx', 'files.zip', 'password', 5)

But this doesn't (it creates a ZIP without password protection):

pyminizip.compress_multiple(['file1.docx', 'file2.docx'], 'files.zip', 'password', 5)
smihica commented 9 years ago

What version of python are you using?

========== In my environment (macosx10.5, python3.4,zlib1.2.5) =============
(env)~/code/pyminizip% ls
COPYING.txt        MANIFEST.in      ...
(env)~/code/pyminizip% python
>>> import pyminizip
>>> pyminizip.compress_multiple(['COPYING.txt', 'MANIFEST.in'], 'files.zip', 'password', 5)
>>> exit()
(env)~/code/pyminizip% ls
COPYING.txt        MANIFEST.in       files.zip       ...
(env)~/code/pyminizip% unzip files.zip
Archive:  files.zip
[files.zip] COPYING.txt password: (password)
replace COPYING.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: n
replace MANIFEST.in? [y]es, [n]o, [A]ll, [N]one, [r]ename: n
(env)~/code/pyminizip%
===============================

It shows it works fine.

ppawiggers commented 9 years ago

Thanks for your quick reply.

Just tested it via the command line, and it's working for both Python 2.7 and Python 3.4. It's just not working in my script, which is weird because I do the exact same thing.

My script:

to_zip = ['file1.html', 'file2.html']
zip_path = '/tmp/files.zip'
password = request.POST.get('password', None)

pyminizip.compress_multiple(to_zip, zip_path, 's3cr3t', 5) # with hardcoded pass it works

pyminizip.compress_multiple(to_zip, zip_path, password, 5) # but this doesn't work

pyminizip.compress(to_zip[0], zip_path, password, 5) # and this DOES work
smihica commented 9 years ago

Hi ;), What version of Python are you using? I updated pyminizip yesterday (v0.2.1 - available on pip). did you try it? in my environment the script you wrote works fine.

import pyminizip
to_zip   = ['README.txt', 'MANIFEST.in']
zip_path = '/tmp/files.zip'
password = 's3cr3t'
pyminizip.compress_multiple(to_zip, zip_path, password, 5)

in unzip command

% unzip /tmp/files.zip
Archive:  /tmp/files.zip
[/tmp/files.zip] README.txt password: (EMPTY)
skipping: README.txt              incorrect password
skipping: MANIFEST.in             incorrect password

and Finder (like explorer in windows) works fine.

My environment is

ppawiggers commented 9 years ago

I just updated pyminizip and now it works great, thanks!

WhoYoung99 commented 7 years ago

Hi, I've encountered similar issues that compress_multiple does not work. I am using Anaconda 3.5 and I was not able to install Pyminizip through command

pip install pyminizip

However, I could install successfully through another fork version pip install git+https://github.com/andrewleech/pyminizip.git

Right now my compress function works fine but each time I execute compress_multiple my python crashes. I guess maybe there's something wrong with the latest build since I can pip install from github.com/andrewleech/pyminizip.git while failing to install from here.

But even though I could install from forked version, my compress_multiple still not working...