Works from the command line, but I can't get it to work with PHP

Ralf Döring
Wed Aug 20 08:43:02 2003

"Adam Cadieux" <> writes:

> I am trying to write a PHP script that will encrypt user data (4 numbers)
> with a symmetric password, but I am having trouble.
> I have looked through the archives and have added:
> putenv("/home/encrypt/.gnupg");

This should be something like

> Also I have made sure that I have make all the files in .gnupg are readable
> I can get this command to work:
> echo system("gpg --warranty --homedir /home/encrypt/.gnupg");
> But when I run this test line nothing happens:
> echo system("echo 1234 | /usr/bin/gpg -o file.gpg --symmetric --homedir
> /home/encrypt/.gnupg", $password);

I`m not a PHP programmer, but assume this doesn`t work because gpg
needs a passphrase for symmetric encryption. You can`t just pass this
as a variable to the system function. According to the PHP
documentation the second parameter to system() ($password in your case)
receives the return code of the called program. To pass the passphrase
to gpg I suggest using the --passphrase-fd option of gpg.