Thursday, 28 August 2014

Encypting and decrypting files with OpenSSL

While this is posted elsewhere in abundance here is the full roundtrip process. This was required due to my workplace deciding that all communications where to be encrypted when sent over email or http so that they could detect information leaks (if its encrypted don't ask me how they know!). To avoid falling foul I've been encrypting diags using the below:-

Create a file with your secret contents
$ cat > confidential.txt
Here is my secret!
<ctrl-d>
Encrypt it, and supply an encryption password
$ openssl enc -aes-256-cbc -salt -in ./confidential.txt -out ./confidential.txt.enc
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
You just can't read the file now... its safe to send over an unencrypted connection.
$ cat ./confidential.txt.enc
Salted__??(?*???q^s????_ۂꠤ?~|~#?`+@
To decrypt, you'll need to agree on the encryption password with your third party, or somehow have sent it securely already.
$ openssl enc -d -aes-256-cbc -in ./confidential.txt.enc
enter aes-256-cbc decryption password:
Here is my secret!

No comments: