Encrypt text with OpenSSL
Hello! I will tell you how to use the utility “openssl” encrypting and decrypting a text file.
The “openssl” has a command “enc”, which is exactly what we need!
Command below using password after “-k” will encrypt file “TEXT.txt” and create file with encrypt text:
openssl enc -k 'U1F54A' -aes256 -e -in 'TEXT.txt' -out 'ENC.txt'
And to decrypt it we use the command:
openssl enc -k 'U1F54A' -aes256 -d -in 'ENC.txt' -out 'DEC.txt'
Quotation marks are optional
Let’s compare the files! If everything is OK, it will not print anything.
cmp -s TEXT.txt DEC.txt || echo "THEY DIFF"