title: GnuPG: How to encrypt/decrypt files using a certain key?
body: <p><strong>Long story short, my question is:</strong> How can I force GnuPG which private/public key to use when encrypting/decrypting files?</p>
  
  <hr>
  
  <h1>Some explanation / Long story</h1>
  
  <p>I have an application that must encrypt files before sending them to S3.</p>
  
  <p>Users can download their files using their browsers from my website, in which case I must first decrypt the files before serving them.</p>
  
  <p>Client side (<strong>delphi 2010</strong>): I'm most likely going to opt for <a href="https://www.eldos.com/" rel="nofollow">OpenPGPBlackbox</a></p>
  
  <p>Server side (PHP 5), I need to figure out how to encrypt/decrypt files with non-interactive commands.</p>
  
  <p>I installed GnuPG on my server, tried this code:</p>
  
  <pre><code>clear_file='/full/path/my-file.zip'
  encrypted_file='/full/path/my-file.zip.pgp'
  
  # Encrypt file
  /usr/bin/gpg2 --encrypt "$clear_file"
  
  # Decrypt file
  /usr/bin/gpg2 --decrypt "$encrypted_file"
  </code></pre>
  
  <p>But it seems that I can't specify, in the commandline, which keys to use.</p>
  
  <p>Each user will have its own public/private key, so I need to be able to specify which key to use to encrypt/decrypt the file in question.</p>
  
  <p><strong>My question is:</strong> How can I force GnuPG which private/public key to use when encrypting/decrypting files?</p>