How to use OpenSSL to encrypt/decrypt files?

aF. picture aF. · Apr 17, 2013 · Viewed 463.1k times · Source

I want to encrypt and decrypt one file using one password.

How can I use OpenSSL to do that?

Answer

Szocske picture Szocske · Apr 17, 2013

Security Warning: AES-256-CBC does not provide authenticated encryption and is vulnerable to padding oracle attacks. You should use something like age instead.

Encrypt:

openssl aes-256-cbc -a -salt -in secrets.txt -out secrets.txt.enc

Decrypt:

openssl aes-256-cbc -d -a -in secrets.txt.enc -out secrets.txt.new

More details on the various flags