1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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

Discussion in 'PHP' started by boon4376, Sep 26, 2010.

  1. #1
    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
     
    boon4376, Sep 26, 2010 IP
  2. jaholden

    jaholden Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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:
     
    jaholden, Sep 28, 2010 IP
  3. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If yo uwant to do anthing securely you probably don't want to use FTP in the first place
     
    krsix, Sep 28, 2010 IP
  4. jaholden

    jaholden Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's why the file is being encrypted! :D
     
    jaholden, Sep 28, 2010 IP
  5. Mo Er

    Mo Er Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    Unfortunately not. What should I do??
     
    Mo Er, Jul 6, 2018 IP