Help - How Do I Encrypt A File (.CSV) with GnuPG and PHP???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
boon4376
Forum Newbie
Posts: 19
Joined: Sun Oct 01, 2006 9:55 pm

Help - How Do I Encrypt A File (.CSV) with GnuPG and PHP???

Post by boon4376 »

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.

Code: Select all

// Encrypt the file
  $gpg = "/usr/bin/gpg";
  $recipient = "matt@xxxxxxx.com";
  $file = "/csvorders/$file_name";
  
  echo shell_exec("$gpg -e -r $recipient $file");
Thanks ahead of time
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Help - How Do I Encrypt A File (.CSV) with GnuPG and PHP

Post by Christopher »

I think there is a PECL Extention, but it might be easier to just exec() gnupg.
(#10850)
Post Reply