Encrypt zip files on Mac OS


TL;DR:
# zip file with password
$ zip -e archive.zip file

# zip folder with password
$ zip -er archive.zip folder/

Example

Let’s say you have the following directory layout:

$ tree
.
└── secrets
    ├── keys.txt
    └── passwords.txt

1 directory, 2 files

To zip a file with encryption:

$ zip -e Archive.zip secrets/passwords.txt

Archive.zip is the compressed archive.

To zip a directory with encryption:

$ zip -er Archive.zip secrets/

To unzip an archive:

$ unzip Archive.zip

You’ll be prompted for the password if it’s encrypted.

And you can also do the same through the GUI:

$ open Archive.zip