I am trying to use subprocess to run an openssl command via a python script to decrypt an already encrypted file with the known password.
The code I have works, but I want to be able to save a password as a variable, i.e. pass = 'password' and input that variable into the subprocess call rather than have it statically as pass:password . Without worrying about how I get the password saved to the variable, and just focusing on passing it as a variable to the subprocess call, is this possible?
I was reading the PASS PHRASE ARGUEMENTS section of the OpenSSL man page, so I'm curious if I should be using one of the other options (env:var, file:pathname, fd:number, or stdin). However it's hard to find examples of them in use, so I'm not sure.
Here is what I have so far:
def decryptfile():
decryptFile = subprocess.Popen(["openssl", "aes-256-cbc", "-d", "-a", "-in", "pw.txt",
"-out", "pw.dec.txt", "-pass", "pass:password"]
)