Sundered Peak

through the mind of kyle tolle

Password Protecting A Zip File on OS X

Every once in a while, I need to zip up some files, so I can send them to someone else, and I want to password protect the zip file.

I’m not actually sure how to do that with a GUI client on OS X. So I use the command line to create a zip file with a password.

I do it infrequently enough that I have to look it up each time. I wanted to leave my future self a little note on how to do this again later.


Zipping A File

To zip up a file and have that be password protected:

$ zip -e your_archive_name.zip the_file_youre_zipping.txt

Zipping A Folder

To zip up an entire folder and have that be password protected:

$ zip -er your_archive_name.zip the_folder_youre_zipping

Entering The Password

For each of the above commands, you’ll be prompted twice to enter your password.

Note: I believe there is a 32 character limit for passwords when using zip.


Choosing a Password

How do I choose a password for this file?

I want it to be long, so it couldn’t be brute forced, but I want it to be easy to type too.

If I email the zip file to someone, I’ll send the password out-of-band, so I want the password to be easy for them to type. Long, complicated passwords can be a pain in the ass to type.

“Oh, you messed up one character, and you don’t know where, so you have to type them all in again.”

The person typing in that password would hate me for choosing it. So I use a passphrase, assembled from a list of random words.

To get a list of random words, I use an online random word generator.

I can use the 8 random words on that page to come up with a 32 character password. One that’s easy for the person to type, but long enough to not be randomly guessed.


There you go, future-Kyle. I hope this helps you out.

PS. Thanks to this article for teaching me how to do this.