How to use openssl command to encrypt/decrypt data in Linux ?

Here we will look how we can encrypt and decrypt data using various encryption algorithms like des, rc, etc in linux. Let us take a test file and first do the encryption and then decrypt it to get the original text. 
 
	Here we have a simple testfile containing some arbitrary text. 
 
	root@egi:~# cat testfile 
 
	this is sample file text 
 
	  
 
	Now encrypt it using “DES”algo and generate a second encrypted file called testfile2. 
 
	root@egi:~# openssl des -in testfile -out testfile2 
 
	enter des-cbc encryption password: 
 
	Verifying - enter des-cbc encryption password: 
 
	root@egi:~# 
 
	  
 
	When we check the file types of encrypted and decrypted data files, we get the following output. 
 
	root@egi:~# file testfile testfile2 
 
	testfile:ASCII text 
 
	testfile2: data 
 
	  
 
	Now to decrypt this encrypted data, we run below command. Here we generate a new file called testfile3. 
 
	root@egi:~# openssl des -d -in testfile2 -out testfile3 
 
	enter des-cbc decryption password: 
 
	  
 
	root@egi:~# cat testfile3 
 
	this is sample file text 
 
	Similar to DES, there are a lot of encryption algo available with openssl, for which you can refer to its man page. I believe now you can easily encrypt and decrypt data on your linux OS and can easily transfer the encrypted files over the internet.

Leave a Reply

Your email address will not be published.