14

I'm using openwrt linux distribution and I want to encrypt a file using AES. How can I do that quickly and easily, and how can I - or someone else -decrypt it again?

Ahmed202
  • 687
  • 3
  • 7
  • 11

1 Answers1

22

The quickest and easiest way is to use openssl util (provided by openssl-util package). For example, to encrypt a file, issue the following command:

openssl enc -aes-256-cbc -in file.txt -out file.enc

To decrypt:

openssl enc -d -aes-256-cbc -in file.enc -out file.dec
Vasily G
  • 760
  • 6
  • 15
  • working on OSX, if I run the two commands you describe, on the decryption I get the error: "error writing output file" and writes an empty file. it does ask for the password though. what could be wrong? – ekkis Nov 10 '17 at 20:53
  • when I try it on Ubuntu I get "bad decrypt" – ekkis Nov 10 '17 at 20:58
  • @ekkis I have just checked these commands - it works for me. Make sure you are in a directory you have permissions to write to (e.g. `cd /tmp`) and you created source file you want to encrypt (`file.txt`) beforehand. – Vasily G Nov 13 '17 at 07:03
  • 1
    This may not be the best answer, at least according to https://security.stackexchange.com/questions/182277/is-openssl-aes-256-cbc-encryption-safe-for-offsite-backup – Paul P Jul 27 '18 at 23:03