How To Create A Password Protected Zip Archive
In my previous post we discussed how to create and extract ZIP archives. This post will teach you how to password protect your ZIP archives. While creating a ZIP archive, optionally, you can encrypt its contents using a password. Take advantage of this option to secure your ZIP archives. This tutorial is short and easy to learn.
How to password protect ZIP archives?
Let us assume we have two text files - abc.txt and xyz.txt in the present working directory.
[sudheer@localhost zip]$ ls
abc.txt xyz.txtLet us now create newarchive.zip and encrypt its contents with a password. The syntax is:
zip archivefilename file1, file2, ... -ewhere
- zip is the command
- archivefilename is the name of the ZIP archive to be created
- file, file2, ... are list of files to be included in the archive
- -e is the option that tells ZIP to encrypt the contents using a password typed in the terminal in response to a prompt
Pretty straightforward, huh? Let us create the zip archive and password protect it.
zip newarchive abc.txt xyz.txt -eThe system now prompts you to type the password. Type your secure password.
zip newarchive abc.txt xyz.txt -e
Enter password: ZIP will make sure that you are not making a typographical mistake while entering the password. Verify your password by typing it again.
zip newarchive abc.txt xyz.txt -e
Enter password:
Verify password: If both the passwords match, the ZIP archive will be created with its contents encrypted with your password.
zip newarchive abc.txt xyz.txt -e
Enter password:
Verify password:
adding: abc.txt (stored 0%)
adding: xyz.txt (stored 0%)Find the newarchive.zip in your present working directory. When you extract this ZIP archive you will be prompted to type your password. Do you recall what command to use to extract the ZIP archive?
unzip newarchive.zip
Archive: newarchive.zip
[newarchive.zip] abc.txt password:If the password you type while extracting is correct, unzip extracts the contents.
unzip newarchive.zip
Archive: newarchive.zip
[newarchive.zip] abc.txt password:
extracting: abc.txt
extracting: xyz.txt If the password entered does not match the encrypted password, unzip will display the warning and exit without extracting the contents of the ZIP archive.
Example of a failed extract attempt:
unzip newarchive.zip
Archive: newarchive.zip
[newarchive.zip] abc.txt password:
skipping: abc.txt incorrect password
skipping: xyz.txt incorrect passwordNow you know how to password protect your ZIP archives, don't you?









Possibility of cracking the password
When I encrypt a zip file using the -p option (I need to use this as I am doing it from a PHP exec() call) or even the -e option in interactive mode, what is the chance of someone cracking the password? I looked up in the internet and there are pages which say that it is possible to crack out the password from a zip archive. LastBit Software has a software that can try over 3 billion passwords over the zip archive per minute! I understand that one must use strong passwords, but is it really easy to break the password? What can I do more to give it a better protection?
Great!
That's a great piece of information to have. I'll probably use it in the near future :)
Thanks for the comment. It
Thanks for the comment. It sure adds one layer of security to your ZIP archive.
With warm regards,
Sudheer
Cool. You don't have to use
Cool. You don't have to use the
zip newarchive abc.txt xyz.txt -p passwordhereanymore. That was really insecure. A friend or colleague overlooking your screen could make your archive less secure immediately.Post new comment