Run Terminal from the Applications > Utilities folder
Type the following command and press [ENTER]:
zip -e output.zip filename.txt
Enter and verify the password when prompted and save this information somewhere secure (1Password secure notes work well). Unless your password entries don’t match the process will run and report files added until complete.
The archive “output.zip”, is now compressed and encrypted with the password entered. The file that was encrypted, “filename.txt” will display a password entry dialog for the user attempting to open it and only open or extract if the user provides the password used to encrypt the archive.
To compress and encrypt multiple files in a folder or group of folders add the ‘r’ option as shown in the example below:
zip -er output.zip ./MyDirectoryToZip
If the path to the directory contains spaces or other special characters you will want to escape these with backslashes as shown below:
zip -er output.zip Path\ With\ Spaces\MyDirectory
The zip utility has MAN help access by typing: