Using gnupg with php - errors

Sean O'Hara
Sun Apr 15 19:07:02 2001

Hello all,

I am trying to execute gnupg from a php script, and I've found some=20
information regarding this on the net, but I've yet to get it to work, I=20=

realise this partly a php problem, but perhaps I can get some help with=20=

the gnupg part from this list.

I am trying to encrypt a small string of data. I am using a script by=20
Richard Lynch as my starting point. I found it here:

Now, I am on MacOSX trying to get this thing to work. I installed an OSX=20=

version of gnupg 1.04, without any problems, and created to sets of =
My idea is to get this to work on my local machine first, then =
get it to work on my web hosting account.

Here is the code I am using:

> putenv("HOME=3D/Users/sohara/");
> =09
> //=A0Explanation=A0follows...
> $command =3D "echo '$data' | /usr/local/bin/gpg -a --batch=20
> --no-secmem-warning -e -u '' -r =
> com'" ;
> =09
> //=A0Actually=A0execute=A0the=A0command
> $result =3D exec($command, $encrypted, $errorcode);
> if ($errorcode)
> {
> echo "Error $errorcode encrypting your data.<br>\n";
> exit;
> }
> $encrypteddata =3D implode("\n", $encrypted);
> echo "This is the encrypted data:<br> $encrypted \n";
And this always gives returns an error number 2. I can't find a list of=20= error numbers at, so the error number isn't very helpful so = far. Does anyone know about the gnupg error numbers, or just using gnupg = with=20 php? Thanks, Sean