We can easily encrypt files ( whether it is text file,audio or video file) in linux using the command line program called gpg.
To encrypt file:
To encrypt files using gpg, open the terminal and type the following syntax:
Eg: gpg -c /home/thegeekylinux/Downloads/test.txt
Here the path is /home/thegeekylinux/Downloads and the file name is test.txt. The file test.text is located at Downloads folder in my home directory.
It will ask you to enter a passphrase which you will need later to decrypt the file. Re-enter the passphrase and your file will be encrypted.
You can see that a new file called test.txt.gpg has been created on the same folder which is the encrypted file. Now you can delete the original file (in this case test.txt).
To decrypt the encrypted file:
You need to decrypt the encrypted file to use it. In order to decrypt the file you need to enter the passphrase you have given while encrypting it.
We can use the following syntax to decrypt the file.
Eg: gpg -d /home/thegeekylinux/Downloads/test.txt.gpg > /home/thegeekylinux/Downloads/test.txt
Here the encrypted file is located at my (thegeekylinux) Downloads folder and the name of the file is test.txt.gpg (see the .gpg extension). I want to save the decrypted file in the same folder itself (Downloads folder in my home directory) as its original name which is test.txt.
After entering the command for decryption, it will ask for the passphrase and if you have given it correctly, it will decrypt the file and save at the location you have specified. Once the process is completed, see the location and you can see the decrypted file test.txt and encrypted file test.txt.gpg.
Now you can open the test.txt file using the text editor program of your choice. You can use the same method for encrypting and decrypting video files,audio file, images etc.
See the below video created by Leszek Lesner about the file encryption in linux.
via [lubuntu screencast]
To encrypt file:
To encrypt files using gpg, open the terminal and type the following syntax:
- gpg -c /path to file/filename
Eg: gpg -c /home/thegeekylinux/Downloads/test.txt
Here the path is /home/thegeekylinux/Downloads and the file name is test.txt. The file test.text is located at Downloads folder in my home directory.
It will ask you to enter a passphrase which you will need later to decrypt the file. Re-enter the passphrase and your file will be encrypted.
You can see that a new file called test.txt.gpg has been created on the same folder which is the encrypted file. Now you can delete the original file (in this case test.txt).
To decrypt the encrypted file:
You need to decrypt the encrypted file to use it. In order to decrypt the file you need to enter the passphrase you have given while encrypting it.
We can use the following syntax to decrypt the file.
- gpg -d /path to file/file name > /path where you want to save file/new name you want to use to save the file
Eg: gpg -d /home/thegeekylinux/Downloads/test.txt.gpg > /home/thegeekylinux/Downloads/test.txt
Here the encrypted file is located at my (thegeekylinux) Downloads folder and the name of the file is test.txt.gpg (see the .gpg extension). I want to save the decrypted file in the same folder itself (Downloads folder in my home directory) as its original name which is test.txt.
After entering the command for decryption, it will ask for the passphrase and if you have given it correctly, it will decrypt the file and save at the location you have specified. Once the process is completed, see the location and you can see the decrypted file test.txt and encrypted file test.txt.gpg.
Now you can open the test.txt file using the text editor program of your choice. You can use the same method for encrypting and decrypting video files,audio file, images etc.
See the below video created by Leszek Lesner about the file encryption in linux.
via [lubuntu screencast]
No comments :
Post a Comment