Create a password-protected ZIP file on Mac OSX

If you want to send someone a file of which the content you prefer to remain anonymous, you can send it in a password protected ZIP file.

It’s not 100% safe, it can still be brute forced and you probably shouldn’t be sending your banking details like this, but it can be useful to send along information this way.

To do so on a Mac, follow these steps (which should be easy if you’re familiar with the command line).

  1. Open your terminal/iTerm
  2. Go to your directory where you have the files/folders you want to zip: cd ~/Desktop/files/
  3. Create the encrypted zip:
$  zip -P YourPass my_zip_file.zip your_original_file.docx
  adding: your_original_file.docx (stored 23%)

Note; if you type the zip command in your shell with an extra space before the command, it won’t be saved in your bash history! Since you’re typing the password directly as a command-line argument, it poses a security risk of staying in your history files.

The zip -P will be followed by the password for your ZIP file. The first argument after that is the name of your new, password protected, zip file and the second argument is the file or folder you want to encrypt.

Note: this article used to refer to the zip -e command, which prompts you for your password interactively instead of typing it directly as an argument to zip -P. That’s the safer way to supply the password (it stays out of your shell history and the process list), so prefer zip -e if you can. Just be aware that both -e and -P use the exact same encryption: the old, weak PKZip 2.0 (ZipCrypto) scheme that ships with macOS. It can be brute forced, so for anything actually sensitive use a tool that supports AES-256, like 7-Zip or Keka .