X

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.

Topher Kessler MacFixIt Editor
Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.
Topher Kessler
3 min read

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:

  1. Type the following command, followed by a single space:

    zip -e ~/Desktop/archive.zip

  2. 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

  3. 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:

  1. Select the Service option when creating a new workflow (this looks like a large gear).
  2. For the service inputs (the menus at the top of the workflow), choose "files or folders" and then optionally choose Finder as the application.
  3. 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).
  4. 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.
  5. 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.
Encrypted disk image Automator workflow
In Automator, apply these actions and settings to the service, and you should be able to use it to create encrypted disk images from selected files in the Finder (click for larger view). Screenshot by Topher Kessler/CNET

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.



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.