Introduction
Sometimes we have files that have to be encrypted using passwords to avoid misuse of the information stored in them. While doing so we might as well store them in a zip format to save space.
People who know us might attempt to guess our password and might get it correct. In this case, what is better than getting a random password that would be unguessable?
Zip
Zip is the most used format to archive files and directories that supports lossless data compression. Compressing the zip files takes up less space in the disk and can easily be retrieved on Windows,macOS and Linux.
Open the required directory and view the files present
Commands Used:
ls : To view the contents of the directory
cd : To change/go to the next directory. the name is appended at the end of the command
Installing zip using CLI
Using 'apt install zip' one can download it. If it was installed previously you will get the result as shown in the image.
Generating a random password
Commands Used:
/dev : The /dev/ directory consists of files that represent devices that are attached to the local system. However, these are not regular files that a user can read and write to; these files are called devices files or special files.
/urandom : A call is made to the driver, and the driver determines how to provide appropriate content.
tr : It is used for translating or deleting characters
A-Za-z0-9 : The range from where the characters have to be chosen
head : It is used to print the top N number of data of the given input
-c : To read for a string
14 : The length of the string generated
Creating the password-protected zip
Commands Used:
zip: To create a zip file
--password : To add the password protection to the file
G9o38eWa : replace it with the password generated and this will be the password of to access the zip
PassZipFile.zip : The name of the resultant zip file followed by the extension .zip
ifykyk.txt secret.txt : The names of the files to be added along with their extension
Removing the original files
The original files have to be removed as only a copy has been stored in the zip.
Command Used :
rm : it is used to remove a file followed by the file name
Accessing the zip
On giving the correct password you can access the files
Unzipping the zip
While unzipping the file, the password is asked (it does not show what you are entering). If the password is correct the original files are restored
Command Used:
unzip : It restores the original contents. the name of the zip file is follows the command
Removing the zip file
The zip file is removed using the rm command and the enc directory is back to it's original form
It's done! You can now make password-protected zip archives for your important files.