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

Adam Cadieux acadieux@pcguardian.com
Wed Aug 20 23:33:01 2003


Thanks Ralf for your advice. I think I need to get my gpg correct befor=
e I
try to integrate it into PHP code.

So I wrote the following command, but it doesn't seem to be working. I =
get
the feeling that I am missing something basic.

echo 1234 | gpg -o encrypted.gpg --symmetric --passphrase-fd 0 < pass.t=
xt

The '1234' is the data I want to encrypt,

What I am really trying to do is something like this

echo $data | gpg -o encrypted_file.gpg --symmetric --passphrase-fd
$password

Cheers,


Adam Cadieux



                                                                       =
                                                               =20
                      Ralf D=F6ring                                    =
                                                                 =20
                      <rdoering@netsys-        To:       gnupg-users@gn=
upg.org                                                        =20
                      it.de>                   cc:                     =
                                                               =20
                      Sent by:                 Subject:  Re: Works from=
 the command line, but I can't get it to work with PHP         =20
                      gnupg-users-admin                                =
                                                               =20
                      @gnupg.org                                       =
                                                               =20
                                                                       =
                                                               =20
                                                                       =
                                                               =20
                      08/19/2003 11:44                                 =
                                                               =20
                      PM                                               =
                                                               =20
                                                                       =
                                                               =20
                                                                       =
                                                               =20




"Adam Cadieux" <acadieux@pcguardian.com> writes:

> I am trying to write a PHP script that will encrypt user data (4 numb=
ers)
> 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
putenv("GNUPGHOME=3D/home/encrypt/.gnupg").


> 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 --homed=
ir
> /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.

HTH,
Ralf

_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users



=