Encrypt Any Files in Linux
By Fahad Ahammed
- 3 minutes read - 428 wordsI 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.
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:
Save it. You can see or read the file by cat command.
Let’s encrypt.
Encrypt file.txt to file.enc using 256-bit AES in CBC mode
It will create an encrypted version of file.txt. You can delete the original file.txt.
Decrypt binary file.enc
There are many cipher like aes-256-cbc.
<td>
<span style="color: #ff0000;">aes-128-ecb</span>
</td>
<td>
<span style="color: #ff0000;">aes-192-cbc</span>
</td>
<td>
<span style="color: #ff0000;">aes-192-ecb</span>
</td>
<td>
<span style="color: #ff0000;">aes-256-ecb</span>
</td>
<td>
<span style="color: #ff0000;">base64</span>
</td>
<td>
<span style="color: #ff0000;">bf</span>
</td>
<td>
<span style="color: #ff0000;">bf-cfb</span>
</td>
<td>
<span style="color: #ff0000;">bf-ecb</span>
</td>
<td>
<span style="color: #ff0000;">bf-ofb</span>
</td>
<td>
<span style="color: #ff0000;">camellia-128-ecb</span>
</td>
<td>
<span style="color: #ff0000;">camellia-192-cbc</span>
</td>
<td>
<span style="color: #ff0000;">camellia-192-ecb</span>
</td>
<td>
<span style="color: #ff0000;">camellia-256-ecb</span>
</td>
<td>
<span style="color: #ff0000;">cast</span>
</td>
<td>
<span style="color: #ff0000;">cast-cbc</span>
</td>
<td>
<span style="color: #ff0000;">cast5-cfb</span>
</td>
<td>
<span style="color: #ff0000;">cast5-ecb</span>
</td>
<td>
<span style="color: #ff0000;">cast5-ofb</span>
</td>
<td>
<span style="color: #ff0000;">des-cbc</span>
</td>
<td>
<span style="color: #ff0000;">des-cfb</span>
</td>
<td>
<span style="color: #ff0000;">des-ecb</span>
</td>
<td>
<span style="color: #ff0000;">des-ede-cbc</span>
</td>
<td>
<span style="color: #ff0000;">des-ede-cfb</span>
</td>
<td>
<span style="color: #ff0000;">des-ede-ofb</span>
</td>
<td>
<span style="color: #ff0000;">des-ede3-cbc</span>
</td>
<td>
<span style="color: #ff0000;">des-ede3-cfb</span>
</td>
<td>
<span style="color: #ff0000;">des-ede3-ofb</span>
</td>
<td>
<span style="color: #ff0000;">des3</span>
</td>
<td>
<span style="color: #ff0000;">desx</span>
</td>
<td>
<span style="color: #ff0000;">rc2</span>
</td>
<td>
<span style="color: #ff0000;">rc2-64-cbc</span>
</td>
<td>
<span style="color: #ff0000;">rc2-cbc</span>
</td>
<td>
<span style="color: #ff0000;">rc2-cfb</span>
</td>
<td>
<span style="color: #ff0000;">rc2-ofb</span>
</td>
<td>
<span style="color: #ff0000;">rc4</span>
</td>
<td>
<span style="color: #ff0000;">rc4-40</span>
</td>
<td>
<span style="color: #ff0000;">seed-cbc</span>
</td>
<td>
<span style="color: #ff0000;">seed-cfb</span>
</td>
<td>
<span style="color: #ff0000;">seed-ecb</span>
</td>
<td>
<span style="color: #ff0000;">zlib</span>
</td>
Second Step: GPG
To encrypt:
To decrypt:
Folder Encrypt:
To encrypt folder it is better to make it a zip file and then use above encrypting procedure.
That’s it.