[PHP] Using GnuPG with PHP

2001-07-19 Thread Jeff Bearer

I saw examples of how to encrypt data with GnuPG in the list archives 
but I'm having problems that aren't mentioned.  I've installed the public 
key in the web server users key ring, and if I run the command as the 
web server user it works just fine.  But when the script runs it I get 
nothing returned and no errors.


$command=echo \$plain\|gpg -e -a --always-trust --no-secmem-warning --batch -r 
public_key;
$encrypted=`$command`;


I've tried with and without the --always-trust, --no-secmem-warning --batch 
in just about any order.  If i try to write it to a file with -o the script
does not create the file and there is still no error.

I'm assuming that STDOUT is returned to $encrypted with the backtick operator, 
how to I see what STDERR of gpg command is?  I figure there has to be something
there.  The only thing I can figure is that the environment for the web server
is different than when you su to the web server user. and that's messing things up.

Any help is appreciated, Thanks.


-- 
Jeff Bearer, RHCE
Webmaster
PittsburghLIVE.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Using GnuPG with PHP

2001-07-19 Thread Maxim Derkachev

Hello Jeff,

Thursday, July 19, 2001, 6:50:18 PM, you wrote:


JB $command=echo \$plain\|gpg -e -a --always-trust --no-secmem-warning --batch -r 
public_key;
JB $encrypted=`$command`;

use popen() in read mode instead. There's a class made by me at
phpclasses.upperdesign.com that do the job.


-- 
Best regards,
Maxim Derkachev mailto:[EMAIL PROTECTED]
System administrator  programmer,
Symbol-Plus Publishing Ltd.
phone: +7 (812) 324-53-53
www.books.ru, www.symbol.ru 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Using GnuPG with PHP

2001-07-19 Thread Jeff Bearer

For anybody who cares I found the problem with the command below,  the 
environment of the webserver user was set to the environment of the user 
who started it, so it could not find the ~/.gnupg directory so I added the
--homedir switch and all is fine.  Thanks for the imput however I'll examine
popen further.





On Thu, Jul 19, 2001 at 10:50:18AM -0400, Jeff Bearer wrote:
 I saw examples of how to encrypt data with GnuPG in the list archives 
 but I'm having problems that aren't mentioned.  I've installed the public 
 key in the web server users key ring, and if I run the command as the 
 web server user it works just fine.  But when the script runs it I get 
 nothing returned and no errors.
 
 
 $command=echo \$plain\|gpg -e -a --always-trust --no-secmem-warning --batch -r 
public_key;
 $encrypted=`$command`;
 
 
 I've tried with and without the --always-trust, --no-secmem-warning --batch 
 in just about any order.  If i try to write it to a file with -o the script
 does not create the file and there is still no error.
 
 I'm assuming that STDOUT is returned to $encrypted with the backtick operator, 
 how to I see what STDERR of gpg command is?  I figure there has to be something
 there.  The only thing I can figure is that the environment for the web server
 is different than when you su to the web server user. and that's messing things up.
 
 Any help is appreciated, Thanks.
 
 
 -- 
 Jeff Bearer, RHCE
 Webmaster
 PittsburghLIVE.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
Jeff Bearer, RHCE
Webmaster
PittsburghLIVE.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Using gnupg with php - errors

2001-04-14 Thread sohara

Hello all,

This has been covered before, but I can't get it to work and I've searched 
all the archives already.

I am trying to encrypt a small string of data. I am using a script by 
Richard Lynch as my starting point. I found it here:
http://www.weberdev.com/get_example.php3?count=1379

Now, I am on MacOSX trying to get this thing to work. I installed an OSX 
version of gnupg 1.04, without any problems, and created to sets of keys. 
My idea is to get this to work on my local machine first, then eventually 
get it to work on my web hosting account.

Here is the code I am using:

   putenv("HOME=/Users/sohara/");
   
 //Explanationfollows...
 $command = "echo '$data' | /usr/local/bin/gpg -a --batch 
 --no-secmem-warning -e -u '[EMAIL PROTECTED]' -r 'alien8@alien8recordings.
 com'" ;
   
   //Actuallyexecutethecommand
   $result = exec($command, $encrypted, $errorcode);

   if ($errorcode)
   {
   echo "Error $errorcode encrypting your data.br\n";
   exit;
   }

   $encrypteddata = 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 
error numbers at gnupg, so the error number isn't very helpful so far. 
Does anyone know about the gnupg error numbers, or just using gnupg with 
php?

Thanks,
Sean

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]