Ever downloaded a folder from a website only to notice that it’s zipped shut and encrypted? These are examples of the ever-wonderful zip file, identified by its extension “.zip.” While a minor annoyance, zip files are your friend, allowing you to compress a number of files into a smaller size.
Here’s how a zip file works and how to do some zip[ing (and unzipping) yourself.
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. .
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—be it .jpg photos, .pdf documents or 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 famous quote from John F. Kennedy’s 1961 inaugural address:
“Ask not what your country can do for you, ask what you can do for your country.”
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.
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.
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.”
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.
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.