Thursday, February 12, 2015

Simple Encryption With OpenSSL

Every once in a while, I need to transfer something from one computer to another, and emailing it to myself is an easy way to do it. But sometimes what I want to transfer isn't something I want out in the open. So the obvious thing to do is encrypt it, and the obvious tool to use to do this is openssl.

Here, so I remember it, is the command for doing this:
openssl enc -des -a -e -pass pass:PASSWORD -in INFILE -out OUTFILE
If you leave out INFILE or OUTFILE, it defaults to stdin and stdout. So you can do:
echo "This is  a secret" | openssl enc -des -a -e -pass pass:PASSWORD
and the encrypted version will be written to the terminal.

To decrypt:
openssl enc -des -a -d -pass pass:PASSWORD -in ENCRYPTED -out DECRTYPED
Or, again:
echo "U2FsdGVkX1+Kqcs+25e+6MiQBr4NT8ykx3POhv9yAf9gnvSn4D2L0A==" | openssl enc -des -a -d -pass pass:PASSWORD
And again you'll get the decrypted version written to the terminal.

No comments:

Post a Comment

Comments welcome, but they are expected to be civil.
Please don't bother spamming me. I'm only going to delete it.