Create 7-zip encrypted archive
Installing 7-zip in Ubuntu
sudo apt install p7zip-full
This is a quick oneliner to compress and encrypt files in folder. This uses symmetric AES-256 encryption.
7z a \
-t7z -m0=lzma2 -mx=9 -mfb=64 \
-md=32m -ms=on -mhe=on -p'verysecretpassword' \
archive.7z directoryoffiles
You can actually leave the password after -p switch empty and the password is asked interactively. This way it's little more secure, but can't be used in scripts because it's usually run in the background. In scripts you can replace it with command substitute or write the password in the commandline, but then remember to read protect the script.
Quick way to disable reading of the file for others than the owner of the file
chmod 600 nameofthescript
Explanation:
Here are the switches explained
Switch | Meaning |
a | Add (directoryoffiles to archive.7z) |
-t7z | 7z format |
-m0=lzma2 | lzma2 |
-mx=9 | Use the '9' level of compression = the best level |
-mfb=64 | Use number of fast bytes for LZMA = 64 |
-md=32m | Use a dictionary size = 32 megabytes |
-ms=on | Solid archive = on |
-mhe=on | 7z format only : Disables listing of files without a password |
-p{Password} | Add a password |
About AES-256 encyption.
I found this article from scrambox website and there is an explanation how the brute force times are calculated.
Here is the re-cap from the site how long it would take the different computers to brute force this encryption
Computing power | Average time to crack using exhaustive search |
---|---|
High-end PC | 27,337,893,038,406,611,194,430,009,974,922,940,323,611,067,429,756,962,487,493,203 years. 27 trillion trillion trillion trillion trillion years |
Fastest supercomputer | 27,337,893,038,406,611,194,430,009,974,922,940,323,611,067,429,756,962,487 years. 27,337,893 trillion trillion trillion trillion years |
2 billion high-end PCs | 13,668,946,519,203,305,597,215,004,987,461,470,161,805,533,714,878,481 years 13,689 trillion trillion trillion trillion years |
Age of the universe | 15,000,000,000 years 15 billion years |
Comments