Here's an example of how to tar and encrypt a list of folders using OpenSSL in Python:
main.py508 chars16 linesExplanation:
tarfile module to create a new tar archive named output_tar_file and add each folder in folders_to_tar to the archive.subprocess module to run the openssl command to encrypt the tar archive using the aes-256-cbc cipher with a pbkdf2 key derivation function, 100,000 iterations, and a salt. We also pass in the password variable as input to the echo command to avoid having to type the password manually. The encrypted tar archive is saved with a filename of output_tar_file.enc.gistlibby LogSnag