Some of the files that are on the server have been encrypted (by me) using openssl using a command similar to:
openssl aes-256-cbc -a -salt -in secrets.txt -out secrets.txt.enc
These files download fine, but I'd like to have them download and be written to their locations decrypted all by the download function.
Is that possible ? If so can someone help me work out how.
The password to decrypt the files will be saved in an array along with several other entries.
You'll need some way to identify the files you want to decompress. The conventional approach is to apply a unique extension. You can then kick off the decompress once the download has completed.
The decompress should be done using system() to run the openssl to do the decompress. I normally advise against using system(), but the openssl API is so bad, that it is a waste of time trying to use it. Further more, there's no guarantee that your code will work if openssl is upgraded. So just stay away from the openssl API, and just use the openssl program. It's the only reliable and portable way to use it.