I have been trying to encrypt files and folders lately. It is fun but useful. You can encrypt any file which can take several years to decrypt for a hacker. That “Several” is not less. According to recent super computer “K Computer” which is the fastest can calculate 8,200,000,000,000,000 (8.2 quadrillion) calculations per second. Lets see how many seconds would take to decrypt an encrypted file by the way i am showing.
First Step: Openssl
Openssl is a good choice to encrypt any file. There are several key choice which will make it harder to decrypt. Our magical cracking device “K Computer” would take 2.5 trillion years to recover an AES-256 key.
You have to make sure that Openssl is installed.
apt-get install openssl
Let, there is a text file named file.txt which contains some lines. You can easily read that file by cat command.
Create a file by terminal:
Put this line by nano:
Our magical cracking device would still take 2.5 trillion years to recover an AES-256 key.
Save it. You can see or read the file by cat command.
Encrypt file.txt to file.enc using 256-bit AES in CBC mode
openssl aes-256-cbc -in file.txt -out file.txt.enc
It will create an encrypted version of file.txt. You can delete the original file.txt.
Decrypt binary file.enc
openssl aes-256-cbc -d -in file.txt.enc -out file.txt.dec
There are many cipher like aes-256-cbc.
Second Step: GPG
gpg -c file.txt
To encrypt folder it is better to make it a zip file and then use above encrypting procedure.
zip -r folder.zip the_folder_to_zip