Skip to main content

Password Protect Zip Files in Mac OS X


OS X Daily

7 hours ago by William Pearson

Zip Password in Mac OS X

Creating a password protected zip file is easy in Mac OS X and does not require any add-ons or downloads. Instead, use the zip utility that is bundled with all Macs.

If you're familiar with the command line, the syntax of the encrypted zip command is as follows:
zip -e [archive] [file]

If you're not sure how to use that, read on to learn how to create zip archives encrypted with passwords. These encrypted zip files will maintain password protection across platforms, meaning you can send a protected zip file to a Windows user and they will still need to enter the password in order to view the contents.

Set a Zip Password in Mac OS X

You can create password protected archives of files and folders:

  1. Launch the Terminal from the Applications > Utilities folder
  2. Type the following command:
  3. zip -e archivename.zip filetoprotect.txt

  4. Enter and verify the password – don't forget this

The resulting archive, in this case named "archivename.zip", is now encrypted with the password provided. The file that was encrypted, "filetoprotect.txt", is now inaccessible without entering that password.

Example: Zipping a Folder and Setting a Password
Here is an example of what this will look like from the command line, in this case we are compressing and password protecting the entire 'Confidential' folder located within the users /Documents directory, and the password protected zip is being placed on the users desktop for easy access:
$ zip -e ~/Desktop/encrypted.zip ~/Documents/Confidential/
Enter password:
Verify password:
adding: ~/Documents/Confidential/ (deflated 13%)

Notice the password will not display, this is normal behavior for the Terminal.

Opening the Password Protected Zip

Despite being created at the command line, you do not need to unzip the file from the terminal, it can be expanded from the Mac OS X Finder or within Windows using standard unzipping apps. Just double click on the file, enter the password, and it will decompress. You can also decompress the zip archive from the command line with:
unzip filename.zip

Here are some use cases for password protected zip archives:

  • Password protecting an individual file or directory
  • Sending a sensitive and encrypted file over an unencrypted network
  • Emailing confidential data to a Windows user
  • Adding an additional layer of security to a hidden folder
  • Password protecting your own backups, outside of Time Machine

While this can provide some protection on a per-file or folder basis, it's always a good idea to password protect the Mac in general with a login requirement on system boot, wake from sleep, and waking from the screen saver.

Comments

Popular posts from this blog

Do You Need to Defragment a Mac’s Hard Drive?

--> Do You Need to Defragment a Mac's Hard Drive? About Focus on Macs In my mailbag this week, I found a couple of questions about defragmenting a Mac's hard drive. This question usually comes from new Mac users, or individuals who switch to the Mac from the Windows environment, where disk defragmentation utilities abound. Some individuals want to know which third-party disk defragmentation app they should use, or wonder why there is no defrag tool in OS X. Courtesy of Apple OS X does have disk defragmentation capabilities, but they're built into the system rather than a separate tool. Since OS X 10.2, Apple has included automatic defragmentation in the Mac OS. In essence, the Mac OS has built-in safeguards that attempt to prevent file fragmentation from occurring; it's also able to repair fragmentation, should it occur. This means that for the average Mac user, there really is no reason to worry about disk defragmentation, at least not as ...

Learn To Code

Even if just to get a better understanding of how computers work or learning how to customize your browsing experience, knowing the basics of coding opens ones eyes to possibilities once only known by a few.  Learn To Code Planet Cocoa If learning to program is even a minor goal for you,  Code Year (via  Brent Simmons ) might be just the encouragement you need. They promise to email you on a weekly basis with coding lessons to help you achieve your goal. I'm one of those computer programmers who downplays the difficulty of the profession, because "if I can do it, anybody can do it!" On the other hand, I have faced challenges that made me question whether I'm vaguely qualified for the job. What it boils down to is that programming is both incredibly simple and impossibly hard, like so many important things in life. There was a time when nobody knew how to write literary prose. The geniuses who invented it shared their special tool with a ...

Tips: Delete duplicate entries in "Open With..." dialog in Finder

Duplicates!!! When you control+click (or right click if you have enabled that option) on Mountain Lion, and there seems to be several duplicate applications listed and/or apps you no longer use, here is a Terminal shell script that will fix that.  Just copy and paste the code below in a Terminal window. /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain user (Terminal can be found using Launchpad or Spotlight) After pasting, hit the Return key and allow time to run, then type "killAll Finder" without the quotes, and Return.  This will rebuild the "Open With..." menu.   If you do not see an immediate effect on the lists, restart your Mac.   Should be no need to restart. (Thanks, JK) Duplicates and old apps gone! If you wish, you can make a Service that will do it using Automator as well: Open Automator (Launch Pad or Applications folder) Create...