How to encrypt and decrypt file in linux using GPG?

This is a very basic concept and may be most of you are aware of the GPG i.e. GNU privacy guard as well as of DES,RC, etc encryption techniques. We have tons of techniques or algorithms available with us to encrypt any data. But here we will look the most common and simple way to doing the encryption using GPG.  Let us first take a short example of GPG encryption. 
 
	1.       Simply run “gpg”with “-c”argument to create GPG file. 
 
	# gpg -c abcfile 
 
	gpg: gpg-agent is not available in this session 
 
	Enter passphrase: 
 
	Here enter the password that you want to give in order to protect the file. 
 
	  
 
	2.       Now transfer the file and tell the same passphrase to the other person. And this file can be simply decrypted using the below command. 
 
	# gpg abcfile.gpg  
 
	gpg: CAST5 encrypted data 
 
	gpg: gpg-agent is not available in this session 
 
	Enter passphrase: 
 
	gpg: WARNING: message was not integrity protected 
 
	  
 
	Now here we can see that the file is simply decrypted. If you had observed the file type of gpg format, it is now DOS executable instead of a simple text. 
 
	# file abcfile 
 
	abcfile: ASCII text 
 
	# file abcfile.gpg 
 
	abcfile.gpg: DOS executable (COM) 
 
	  
 
	So from next time whenever you see DOS executable and you know that this file is encrypted, you can have a try to GPG for decoding the text. Hope this article will help you in encryption and decryption of your important files. 

Leave a Reply

Your email address will not be published.