Situatie
Solutie
Pasi de urmat
Step a) Encrypting a message in OPENSSL
1)-Type the command below to list the contents of the encrypted secret_message.txt text file on the screen:
cat secret_message
2) -In the same terminal window, run the following command to encrypt the text file using AES-256. The encrypted file will be saved as message.enc. OpenSSL will prompt you to enter and confirm a password. Ensure you provide the password as requested and remember it for future use.
openssl aes-256-cbc -in secret_message -out message.enc
-Once the process is complete, use the cat
command to view the contents of the message.enc file.
cat message.enc
3)-To make the file readable, rerun the OpenSSL command, this time including the -a option. The -a option instructs OpenSSL to encode the encrypted message in Base64 format before saving it to a file.
openssl aes-256-cbc -a -in Secret_message -out message.enc
-Again, use the cat command to view the contents of the newly generated message.enc file
cat message.enc
Step b) Decrypting a message in OPENSSL
A similar OpenSSL command can be used to decrypt the message.enc file.
-Run the following command to decrypt message.enc:
openssl aes-256-cbc -a -d -in message.enc -out decrypted_Secret_message.txt
OpenSSL will prompt you to enter the password used during encryption. Provide the same password.
Once the decryption is complete, OpenSSL will save the decrypted message in a text file named decrypted_Secret_message.txt
-Use cat to display the contents of decrypted_letter.txt.
Leave A Comment?