0

Is there a way to get the output value from a subprocess that decrypts a file? Getting a variable with the output and creating the decrypted file in the directory are both good solutions - I just need to get the decrypted value.

Code:

decryption_result = subprocess.run(['openssl', 'decrypt', '-inkey', private_key_file,'-in', message_file, '-out', name])

1 Answers1

1

Add the argument stdout=subprocess.PIPE and you could use

decryption_result.stdout.decode("utf-8")

EDIT: From the official documentation : https://docs.python.org/3/library/subprocess.html#subprocess.check_output

decryption_result = subprocess.run(['openssl', 'decrypt', '-inkey', private_key_file,'-in', message_file, '-out', name], stdout=subprocess.PIPE)
decryption_result.stdout.decode("utf-8")