Decrypting data with GnuPG
| From: | Pierre-Luc Soucy | Date: | Wed, 28 May 2003 23:14:43 +0000 |
| Subject: | Decrypting data with GnuPG | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-149327@lists.php.net to get a copy of this message | ||
Hi,
I would like to decrypt data encoded with GnuPG without including the private key passphrase in the command to prevent people from viewing it with "ps".
Here is the code I wrote:
====
$command = "/usr/bin/gpg --homedir=/path/to/.gnupg --no-secmem-warning --always-trust --yes --output /path/to/output.txt --decrypt /path/to/testtext.asc";
$passphrase = '***********';
$fp = popen($command, 'w+');
fputs($fp, $passphrase);
pclose($fp);
print "Done";
exit;
======
I assumed that the fputs() function would write the passphrase at the prompt, but that doesn't seem to be the case - the command does not create the output.txt file when ran by the PHP program (which is running as a CGI under my user BTW) while it works when ran from the shell.
Any idea why?
Thanks!
Pierre-Luc Soucy