Encrypt zip files in Mac

# zip file with password
$ zip -e path/to/archive.zip path/to/file

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


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