Sunday 3 April 2022

openSSL: Encrypt and decrypt the data using secret key algorithm

In this post, I am going to explain how to encrypt and decrypt the data using AES symmetric key encryption algorithm.

 

Step 1: Create demo.txt file with some content.

 

demo.txt 

Hello World

 

Step 2: Execute below command to encrypt the contents of file ‘demo.txt’. Encrypted content is copied to encryptedData.bin.

 


openssl enc -aes-256-cbc -in demo.txt -out encryptedData.bin

 

You need to supply a password to encrypt the data. For example, I given ‘password123’ as password.

 

$openssl enc -aes-256-cbc -in demo.txt -out encryptedData.bin
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
$
$ls
demo.txt		encryptedData.bin

 

Step 3: Execute below command to decrypt the file

openssl enc -aes-256-cbc -d -in encryptedData.bin -pass pass:password123

$openssl enc -aes-256-cbc -d -in encryptedData.bin -pass pass:password123
Hello World

 


 

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment