How to Encrypt a File or Folder in OSX

You need to email a file or folder of files to someone, but the information is sensitive. These slightly geeky but easy to follow instructions will show you how to do it.

We’re going to compress the file(s) into a single zip file that’s encrypted by issuing one single command into the Terminal.

When you email the zipped file to a Mac or Windows user, all they will have to do is double click the file and enter the password you used to encrypt the file. Please after doing this do NOT put the password in the body of the email! Call them, text them, direct tweet them, just don’t put it in the email.

One File One Folder

wpid3283-media_1347422597307.png

For this example, we’ll start with a text document entitled bob.rtf and a folder is called bob_folder. Ready?

Open Terminal

wpid3284-media_1347422743990.png

Launch the Terminal, located inside Applications/Utilities.

Terminal

wpid3285-media_1347422830424.png

Print Working Directory

wpid3286-media_1347422973329.png

Type pwd to print the working directory which will tell us where in the directory structure Terminal opened. In the image above, it shows I’m in my user directory allison on the hard drive fatso. I have a bit of a non-standard setup, you should see /Users/yourusername. If you don’t, type

    cd ~

which means change directory to my user home directory.

Change Directory to Desktop

wpid3287-media_1347423333585.png

By typing

    cd Desktop

we have moved down into the desktop folder. Note that Desktop must start with a capital D.

List Files

wpid3288-media_1347423458955.png

If you type

    ls -l

you’ll get a listing of all the files on your desktop. I do this just to ensure that I know I’m in the right place and to be sure the files are there. If you’re like most people you might have a lot of files on your desktop, but just look to make sure the file and/or folder you want to encrypt is there.

And Now to Zip

wpid3289-media_1347423654127.png
  1. All the heavy lifting is over. Simply type:
    zip -e bob.zip bob.rtf

That zips bob.rtf up, encrypts it, and makes it into bob.zip.
2. Now Terminal will ask you (twice) for the password to UNencrypt the file <– Remember this password!
3. Let’s verify the file was created by typing

    ls -l

4. As you can see we now have bob.rtf AND bob.zip

Test bob.zip

wpid3290-media_1347424056311.png

In the Finder, double click on bob.zip and it should launch the Archive Utility built into OSX and then prompt you for a password to open the file.

Bonus Tip – Zip and Encrypt a Folder

wpid3291-media_1347424247730.png

You only have to add two characters /* to the command to encrypt a folder. This time our folder is called bob_folder so the command is:

    zip -e bob_folder.zip bob_folder/*

If you have folders within that folder, be sure to add -r to the command to recursively archive the folder:

    zip -er bob_folder.zip bob_folder/*

As you can see above you’ll be prompted twice for the password to encrypt the file and then you’re done! Just as before, a Windows or Mac user can double click this encrypted zip file and it will delightful expand into a nice folder when the password is entered.

Final Word

Just in case you missed it the first time, please after going to this much care do NOT put the password to unencrypt the file into the email itself! Call the person, text, them, carrier pigeon if you have to, just don’t put the two things together!

3 thoughts on “How to Encrypt a File or Folder in OSX

  1. […] How to Encrypt a File or Folder in OSX […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top