How to Zip, Unzip, and Encrypt Your Files

Photo credit: Getty/Photo Illustration by PM
Photo credit: Getty/Photo Illustration by PM

From Popular Mechanics

Ever download a folder full of files, only to notice all of the documents inside are zipped shut and encrypted—basically the digital version of Fort Knox? These are examples of the ever-wonderful, yet confounding zip file, identified by its extension, ".zip."

While the extra steps you must take to open these kinds of folders can be a minor annoyance, zip files really are your friend. Not only can you compress huge files into a compact size for sharing, but you can easily lock down the contents so that only the intended recipient can see what's inside.

Dive deeper. Read best-in-class tech explainers and get unlimited access to Pop Mech, starting now.

Here's how a zip file works, and how to do some zipping (and unzipping) yourself.

What Is a Zip File?

Back in the 1980s, the late computer programmer Phil Katz invented a set of algorithms for compressing files to take up less space. At his company, PKWARE, Inc., the programs were known as PKZIP and PKUNZIP. Originally, the software was built to shrink files into 50 to 70 percent of their original size so that more files could fit on physical floppy disks.

"A zip file takes a directory of, say, 25 files and makes it into one file," Samir Khuller, chair of Northwestern Engineering’s Department of Computer Science, tells Popular Mechanics.

Eventually, compression algorithms became so popular that other companies, such as Nico Mac and Netzip, began developing zip and unzip programs. Today, the primary zip/unzip algorithms are public domain, so anyone could, in theory, write their own program if they wanted.

Most of us aren't using floppy disks anymore (hopefully), so zip files are more about maintaining the RAM space on our laptops or computers, downloading files from the internet more quickly, or locking down compressed files for security purposes.

One of the most common uses for zip files is in software downloads. Zipping the program saves space on a company's servers, makes it faster for download, and keeps the hundreds or potentially thousands of separate files all together.

How Does Compression Work?

Photo credit: pick-uppath - Getty Images
Photo credit: pick-uppath - Getty Images

At its core, compression is about reducing the number of bits and bytes in a file. When the folder or single item is accessed again, an unzip algorithm should fill those bits and bytes back in and the file should return to its original state.

That's due to the redundancy inherent in so many file types on our computers. Most kinds of files—from .jpg photos, to .pdf documents, to even .mp4 videos—use similar lines of code over and over again. Compression algorithms take advantage of this repetition by listing the original information once and referring back to it anywhere else it appears in the code.

Khuller explains that compression algorithms like those used in .zip files will evaluate a file and look for patterns. Based on those specific redundancies in the code, the algorithm will adjust accordingly. That means each compression is file-dependent, and the unique code to expand the file back to its original format is stored right within the file, too.

"If I write a book, there is a good chance that many of the words appear multiple times," Khuller says.

Take a look at the following. It's a famous quote from President John F. Kennedy's 1961 inaugural address:

This line has 17 separate words, but they're not all distinct. There are 61 letters, 16 spaces, a comma and a period. If we think about each of these characters taking up one unit of space, then the total file size for our sentence is 79 units. To squish it down, we can check for redundancies.

Computers use compression programs that are typically some variant of the LZ adaptive dictionary-based algorithm (the LZ is for Lempel and Ziv, the algorithm's creators). Specific systems for arranging the information, or dictionaries, can vary, but a simple method is to use a numbered list. So in the Kennedy example, this could be our dictionary:

(1) Ask (2) What (3) Your (4) Country (5) Can (6) Do (7) F0r (8) You.

The sentence can be rewritten as this now: "1 not 2 3 4 5 6 7 8, 1 2 8 5 6 7 3 4."

You can imagine that if a program went through and rewrote Kennedy's entire speech in this manner, it could be significantly compressed, as the words in the list above will more than likely pop up again and again.

How to Zip a File

🤐 On a Mac:

To compress a file or a folder, press Control + click or tap it using two fingers, then choose Compress from the shortcut menu.

If you compress a single item, the compressed file takes on the name of the original item, plus the .zip extension. So if an image is originally titled "photo.jpg," you can expect that the compressed version will take the name "photo.jpg.zip."

🤐 On Windows 10:

Right click in a blank area on your desktop > select New > select Compressed (zipped) Folder.

How to Unzip a File

🤐 On a Mac:

To expand an item in a .zip format, simply double click the file or folder. The exception to this rule, of course, is if the folder is password-protected or encrypted, in which case you'll also need a password or encryption key.

🤐 On Windows 10:

Simply right click the folder, then select Extract All.

How to Create Your Own Zip File

🤐 On a Mac:

Select a group of files that you'd like to compress > right click and select Compress [file name].

🤐 On Windows 10:

Navigate to File Explorer on the taskbar > Select all files you'd like to add to your zip folder > Right click and select Send to > Select Compressed (zipped) folder > Rename your zip file and press enter.

How to Encrypt a Zip File

Photo credit: Matthias Kulka - Getty Images
Photo credit: Matthias Kulka - Getty Images

Whether you run a PC or a Mac, there are two primary forms of encryption for .zip files. The first is called ZipCrypto, but it's relatively easy to crack, at least according to the organization Info-ZIP, which rated it "quite weak."

The second is called AES-256, which actually wasn't designed for zip files—it's a strong encryption technique used widely across the board. As long as you use a strong password, this is the practically unbreakable option.

If you go the AES-256 route, you'll need a third-party software program in order to encrypt the zipped folder, because the native zip/unzip programs in both Windows and MacOS do not support this option. A popular alternative to use, in either case, is 7-zip, which is free and open source. Once you've downloaded that software, you can add a password and lock down the zip file.

⚠️Just keep in mind that no matter what type of encryption you use, anyone with the zip file can see its contents—file names and all.

The greatest thing about zip file encryption is that it's so reliable—so much so, in fact, that one person with $300,000 worth of Bitcoin actually locked himself out of his account, because he had completely forgotten the private key that he must use to retrieve the digital cash.

The private key was tucked safely away inside—you guessed it—an encrypted, zipped folder.

You Might Also Like