Using gnupg with php - errors

Sean O'Hara sohara@sohara.com
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:
http://www.weberdev.com/get_example.php3?count=3D1379

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 =
keys.=20
My idea is to get this to work on my local machine first, then =
eventually=20
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 'sohara@sohara.com' -r =
'alien8@alien8recordings.
> 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 gnupg.org, 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