Compress files and encrypt symmetrically with AES using OpenSSL

Compress the "folder" folder with tar and then encrypt it with the symmetric encryption method aes-256-cbc using OpenSSL and save it as a file:

tar cz folder/ | openssl aes-256-cbc -pbkdf2 -e > folder.tar.gz.enc

Decrypt and unpack the file again:

cat folder.tar.gz.enc | openssl aes-256-cbc -pbkdf2 -d | tar xzv

Last modified: Dec. 15, 2022

binsec GmbH
binsec GmbH is a consulting firm for information security and was founded in 2013 by security experts. Our team consists of experienced, certified specialists with different areas of expertise. Due to our extensive expertise in many different IT security fields, we can support our customers with a wide array of issues. Most of our customers are medium-sized companies, for whom security is pivotal to success.