'how to run .sh file with .key file and str as an input from php with python

I want to decrypt some text with a .sh file, inside the sh file is like this:

#!/bin/bash

private=$1
temp="./tmp"
out=$3

if [[ $# -lt 2 ]] ; then 
    echo "Usage: decrypt <private_key> <encrypted_secret> <optional:output_file>"
    exit
fi
echo $2 > $temp.base64
encrypt=$temp.base64

# decryption logic
openssl base64 -A -d -in $encrypt > $temp.bin
openssl pkeyutl -decrypt -inkey $private -in $temp.bin -out $temp.txt -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 
# end of decryption logic

cat $temp.txt

if [[ $out != "" ]]; then 
    echo "result: $out"
    cat $temp.txt > $out
fi

rm $temp*

as you can see I can use it with decrypt <private_key> <encrypted_secret> optional:output_file I can run the sh file with cmd like this:

$ ./myshfile.sh myprivatekeyfile.key YpK2WBeS49JmbHvZhiQ6VmavukW6pb8uPEx9t8+BMpaGvXenSLo+SlPGT8gFEYImfiWHXMWgVBpqUQIlVv0urSAOT6VUI9+rOFwfCcRuWgftU61NfMzy1ziqotLCBBVQ7Sqo8kF+s5pi+5l+FwcPeDgEonbPu/PTIfbFi2XfIwfpZa0BynqLK1e1QHG9BW8d20BHtB+s5kz8BNorY3qF8BHHpln1fWA8d1CDecPUndCGetB5BaSFh+w1XAuPYJxzgYsBgaGamFTQTpgbN94KOlGPVnEElXOdMfc485As/qIj9vR1A7vG++FT/BDYEB1/FmbrntqpSpg6EiW9XcVO9Q==
ac5f3dfff23c59a488c37158b3446597

can anyone suggest me how to do it in a python file?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source