From: Ray on
Hello all,

I'm trying to use the gnupg extension and I think everything is properly
installed.

I'm just using test data. I'm encrypting and then immediately decrypting. But
the decryption is failing with a unhelpful error message.

error message :
Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in
/path/to/test2.php on line 18

any help or suggestions would be very much appreciated. details follow.
Ray



full output:

raw data: this is a test


encoded data:

-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.11 (FreeBSD)

hQIOA9qOyyMyQ2/bEAgArxLuVw5eShkL+/g9SCGcBm5/J1G78zrh6dWFisPFqWg1
MP3zj/QnWiD9zEtLmGJazP51pV2TpySpEbILze8sz6c/imRBYLrHhbxO6W1LJqXq
rALUPDIe4qKtM7mC+K9EdFdkYRzWxi45eTK1DQtQazhqelWIb1NuaVu8vUKk/pIy
duE0juP2j+8OHIlx36sUcATkvBO5a7Ak9tGUT5T5lRqjMzKa6TPuCsZukmVh43BG
uqpz7H83LinwOCfUnyq3R2e/vIM2cv8t7jz17acOfYslonMxNz54i8jR8COmCmLY
NhGORZUSLauyWGxAIDvkDcTFD4Jd5KxaXcMPEE7zwAf9HUWmKtqOqn825AjlBxNj
7gXEOtpsRMiYiYuISzHvitpPWXQPOPsoGnPRZZBvCNJcvAgg6hMx5c4Y7tGXTsma
2hkC9f4959kBwiGAFnQxJqz2pMDW+N3X23f+kwSrU7KoNrhnxUV1ywcUGaebwYM8
emIygCm6mS7T81JtXxhMto0sSqeE/zwHc3/03/KP57V7j2tHib4dN9ZOfB6yiubF
PIwog0JYagjOfyNdGh3vRzvcYdDOqyWMgtY6XpZJwPESJlOADHVt5n844oHthRD3
MJVjwqjEz5qQiPq+kOmd4AdkpkEkRcCweYNEXVXPxpmlrduuu8kc4wsA5v3YXZ/C
x9JNAVKW9tdPSxDoxbEKyAhVdurQAxmYe7FaCLl74lACQaUg/Otwb86pjUBesgx6
mXhQv+epG71sKY+LSDxGi8dSgbOOmfI2L09zy9XTEQ4=
=85vG
-----END PGP MESSAGE-----


[if this line is blank, the decrypt key should have been added correctly]]

Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in
/path/to/test2.php on line 18


decoded data:




Code:

<?php
$raw_data="this is a test";
$passphrase="test";
$recipient="me(a)example.com";

putenv('GNUPGHOME=/www/ohfinder/keys');
$gpg = new gnupg();
$gpg -> seterrormode(gnupg::ERROR_WARNING);
echo "raw data: $raw_data<br>";
$gpg->addencryptkey($recipient);
$encrypted = $gpg->encrypt($raw_data);
echo "<br><br>encoded data: <pre> $encrypted</pre><br>";

$gpg->adddecryptkey($recipient, $passphrase);
echo $gpg -> geterror();
echo "[if this line is blank, the decrypt key should have been added
correctly]]";
echo '<br>';
$plaintext = $gpg->decrypt($encrypted);
echo $gpg -> geterror();
echo "<br><br>decoded data: <pre> $plaintext </pre>";
?>
From: Ray on
On Monday 13 April 2009 10:17:28 Ray wrote:
> Hello all,
>
> I'm trying to use the gnupg extension and I think everything is properly
> installed.
>
> I'm just using test data. I'm encrypting and then immediately decrypting.
> But the decryption is failing with a unhelpful error message.
>
> error message :
> Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in
> /path/to/test2.php on line 18
>
> any help or suggestions would be very much appreciated. details follow.
> Ray
>
>
>
> full output:
>
> raw data: this is a test
>
>
> encoded data:
>
> -----BEGIN PGP MESSAGE-----
> Version: GnuPG v2.0.11 (FreeBSD)
>
> hQIOA9qOyyMyQ2/bEAgArxLuVw5eShkL+/g9SCGcBm5/J1G78zrh6dWFisPFqWg1
> MP3zj/QnWiD9zEtLmGJazP51pV2TpySpEbILze8sz6c/imRBYLrHhbxO6W1LJqXq
> rALUPDIe4qKtM7mC+K9EdFdkYRzWxi45eTK1DQtQazhqelWIb1NuaVu8vUKk/pIy
> duE0juP2j+8OHIlx36sUcATkvBO5a7Ak9tGUT5T5lRqjMzKa6TPuCsZukmVh43BG
> uqpz7H83LinwOCfUnyq3R2e/vIM2cv8t7jz17acOfYslonMxNz54i8jR8COmCmLY
> NhGORZUSLauyWGxAIDvkDcTFD4Jd5KxaXcMPEE7zwAf9HUWmKtqOqn825AjlBxNj
> 7gXEOtpsRMiYiYuISzHvitpPWXQPOPsoGnPRZZBvCNJcvAgg6hMx5c4Y7tGXTsma
> 2hkC9f4959kBwiGAFnQxJqz2pMDW+N3X23f+kwSrU7KoNrhnxUV1ywcUGaebwYM8
> emIygCm6mS7T81JtXxhMto0sSqeE/zwHc3/03/KP57V7j2tHib4dN9ZOfB6yiubF
> PIwog0JYagjOfyNdGh3vRzvcYdDOqyWMgtY6XpZJwPESJlOADHVt5n844oHthRD3
> MJVjwqjEz5qQiPq+kOmd4AdkpkEkRcCweYNEXVXPxpmlrduuu8kc4wsA5v3YXZ/C
> x9JNAVKW9tdPSxDoxbEKyAhVdurQAxmYe7FaCLl74lACQaUg/Otwb86pjUBesgx6
> mXhQv+epG71sKY+LSDxGi8dSgbOOmfI2L09zy9XTEQ4=
> =85vG
> -----END PGP MESSAGE-----
>
>
> [if this line is blank, the decrypt key should have been added correctly]]
>
> Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in
> /path/to/test2.php on line 18
>
>
> decoded data:
>
>
>
>
> Code:
>
> <?php
> $raw_data="this is a test";
> $passphrase="test";
> $recipient="me(a)example.com";
>
> putenv('GNUPGHOME=/www/ohfinder/keys');
> $gpg = new gnupg();
> $gpg -> seterrormode(gnupg::ERROR_WARNING);
> echo "raw data: $raw_data<br>";
> $gpg->addencryptkey($recipient);
> $encrypted = $gpg->encrypt($raw_data);
> echo "<br><br>encoded data: <pre> $encrypted</pre><br>";
>
> $gpg->adddecryptkey($recipient, $passphrase);
> echo $gpg -> geterror();
> echo "[if this line is blank, the decrypt key should have been added
> correctly]]";
> echo '<br>';
> $plaintext = $gpg->decrypt($encrypted);
> echo $gpg -> geterror();
> echo "<br><br>decoded data: <pre> $plaintext </pre>";
> ?>


Any suggestions, Anyone?
Ray
From: "Ian" on
On 20 Apr 2009 at 11:37, Ray wrote:

<snip>

> Any suggestions, Anyone?
> Ray

Hi,

I adapted these scripts for my own user and have not had any problems:

http://www.theoslogic.com/scripts/php-gpg/

It does not use the gnupg extension at all but popen() or proc_open().

Regards

Ian
--



 | 
Pages: 1
Prev: Am I being hacked?
Next: Soap Client Help