How to quickly create an encrypted archive in OS X
There are several methods for creating encrypted archives, including Terminal-based options and Finder services.
To make sending multiple files by e-mail or other means easier, Apple includes a quick Finder contextual menu option to zip a selection of files and folders into an archive, which not only will ensure that the files stay together, but can also greatly reduce their size for the file transfer. While convenient, Apple does not provide a means to encrypt or secure the contents of the ZIP archive with a password; however, there is a way to do this if needed.
To place a file or folder into a ZIP file that is encrypted, you will need to use the Terminal and perform the following actions:
- Type the following command, followed by a single space:
zip -e ~/Desktop/archive.zip
- Drag the folder containing your desired files to the Terminal window, so the command looks like the following:
zip -e ~/Desktop/archive.zip /Path/to/folder
- Press Enter, then supply the password to use for the archive, and the encrypted file will appear on your desktop.
This method may be a bit cumbersome , and it's not a very good implementation of encryption for files in OS X, either, so if you plan on encrypting collections of files regularly, your best bet is to use alternative means.
Apple's preferred encryption container for files is a disk image, which is a wrapper format that mimics a physical disk (hard drive or DVD). These images can be created using Disk Utility by choosing an option for disk images (i.e., from a folder or a new blank image) from the File > New menu. While this option is robust, having to use Disk Utility makes it a touch inconvenient to use; however, you can set up a Finder service using Automator that will allow quick access to making an encrypted disk image from any selection of files and folders.
To do this, open the Automator program and perform the following steps:
- Select the Service option when creating a new workflow (this looks like a large gear).
- For the service inputs (the menus at the top of the workflow), choose "files or folders" and then optionally choose Finder as the application.
- Next go to the Action library and drag the New Disk Image action to the workflow area (search for it if you cannot locate it).
- Change the image options so Size is set to size the disk image to fit its contents, and also check the Encrypt check box. You can name the volume and disk image file names if you wish; otherwise (and perhaps more intuitively) they will be named after the originating files and folders. By default the new image will be created on the desktop, but you can change this location as well.
- Finally, the default action when the image is created is to open it, but you can change this to reveal the image in the Finder. To do this, select "Unmount and return the image file" in the New Disk Image action (this is the last option), and then locate and add the Reveal Finder Items action to the workflow.
When finished, save the workflow and give it a name such as "Encrypted Disk Image from Selection," after which it will become available in the Services menu in the Finder and other applications that can pass files and folders to system services. To use the new service you have just created, select some files that you would like to encrypt, and right-click them to show the Finder's contextual menu. In the Services submenu, choose Encrypted Disk Image from Selection, and the service will prompt you for a password. After supplying the password, the system will reveal the new disk image in the Finder, which should be compressed and encrypted using AES 128-bit encryption.