I have a checkout system that takes order information and places it into a .csv file. I need to encrypt this file using GnuPG so that I can upload it securely to my fulfillment houses ftp server. I have CPANEL in my hosting account and have setup a key to do some testing with. I am programming with PHP. What is sample code I could use to encrypt this file? Do I use the file handle? encrypt using the file's location on the server? I really have no idea what I am doing as far as encrypting files goes and I need some help. This is code I am using at the moment and it doesn't seem to be doing anything. Keep in mind I have a shared hosting account and my CPANEL has a section built in for creating / managing GnuPG keys so I believe I have the capability setup. // Encrypt the file $gpg = "/usr/bin/gpg"; $recipient = "matt@xxxxxxx.com"; $file = "/csvorders/$file_name"; echo shell_exec("$gpg -e -r $recipient $file"); Code (markup): Thanks ahead of time
This should work: $gpg = "/usr/bin/gpg"; $recipient = "matt@xxxxxxx.com"; $file = "/csvorders/$file_name"; $encrypted_data = shell_exec("$gpg -a -e -r $recipient -o - $file"); // Now, $encrypted_data will contain the encrypted version of $file PHP: