To tar multiple folders and encrypt them using OpenSSL in Python, you can use the following code:
main.py566 chars21 lines
This code uses the tarfile
module in Python to create a tar file containing the specified folders. Then, it uses the subprocess
module to invoke OpenSSL's command-line interface to encrypt the tar file using AES 256-bit encryption with a salt and a password. Finally, the original tar file is removed for security purposes.
To decrypt the encrypted tar file using OpenSSL, you can use the following command in the command line:
main.py85 chars2 lines
This command will prompt you to enter the password you used to encrypt the file. Once the correct password is entered, the encrypted tar file will be decrypted and saved as my_files.tar
.
gistlibby LogSnag