You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Password Protect a zip file

I simply need to PW protect a zip file for emailing to a Windows user who will not be keen on downloading software to open a dmg file.


I see another post last year indicating to use the zip -e NAMEOFZIPFILE.zip NAMEOFZIPFILE.txt command in Terminal, but my file is not a txt file - it's already a zip file. I keep getting the 'nothing to do' message.


I've also tried dragging the file into Terminal after using zip -er NAMEOFZIPFILE.zip command, and that gives me the same error after entering my PW.


How do I do this??



Posted on Jan 26, 2021 9:19 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 26, 2021 2:12 PM

My issue was that I didn't have a text file, I had a folder containing PDFs and excel.


I ended up moving the folder to my desktop and executing the following commands in Terminal, which generated a PW protected zip file on my desktop, which I was able to send. Hopefully it prompted a PW on the receiving end, but not so confident based on others' responses!


cd desktop <RETURN>

zip -er FILENAME.zip FILENAME <RETURN>

PASSWORD <RETURN>

VERIFY PASSWORD <RETURN>

6 replies
Question marked as Top-ranking reply

Jan 26, 2021 2:12 PM in response to peach_kitten

My issue was that I didn't have a text file, I had a folder containing PDFs and excel.


I ended up moving the folder to my desktop and executing the following commands in Terminal, which generated a PW protected zip file on my desktop, which I was able to send. Hopefully it prompted a PW on the receiving end, but not so confident based on others' responses!


cd desktop <RETURN>

zip -er FILENAME.zip FILENAME <RETURN>

PASSWORD <RETURN>

VERIFY PASSWORD <RETURN>

Jan 26, 2021 1:24 PM in response to peach_kitten

You have a folder arbitrarily named TestZip. You place your file NAMEOFFILE.txt in that folder. Now, you can apply a password to that TestZip container that Windows 10 will respect, and open a dialog for that password during the extraction:


zip -er TestZip.zip ./TestZip


This will prompt you for a password, which it will not echo, and a verify challenge to re-enter that password. On the Windows 10 side, there will be a password challenge before the folder and its file contents can be extracted:



You can not set a zip password on an individual file, but rather the enclosing folder that you zip.

Jan 26, 2021 1:33 PM in response to peach_kitten

If you pass in an existing .zip file as the file to be zipped/encrypted, you will end up with an encrypted zip file containing a zip file, and the recipient will have to decompress it twice.


Therefore you should start with your standard, non-encrypted, non-zipped file - let's call that NameOfFile.txt


Then the command:


 zip -e my.zip NameOfFile.txt


should prompt you for a password, then use that password to encrypt the txt file into the resulting my.zip file.


From your description, you say "...but my file is not a txt file", but you are passing a text file into the zip command, so that may be where the problem lies.


Jan 26, 2021 2:00 PM in response to VikingOSX

Wow. That seems like a significant bug in ZIP.


If Windows is decrypting the file without prompting for a password then either zip never applied the encryption (in which case it should have warned you), or the encryption is so weakly applied that the content is readable anyway (e.g. it doesn't actually encrypt the data, just stores a flag about the password).


The man page for zip indicates that encryption is supported at the zip file level, not related to its contents (folders vs. files), A quick test here does show binary-level differences between the same file zipped with and without a password.



Password Protect a zip file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.