1

i am completely stuck with a pgp problem, but I guess it's more a logical than a technical problem - anyway, i don't get it.

The goal is to encrypt a file with gpg4win (www.gpg4win.de/index.html) and decrypt it with PHP (gnupg).

First thing I did, I've created a certificate with gpg4win, set a passphrase and encrypted a simple text file (ASCII). Then I upload the file and tried to decrypt it with the following code:

$content = file_get_contents("some-test-data.asc");
$gpg = new gnupg();
$gpg -> adddecryptkey("MYFINGERPRINT","my.pass.phrase");
$plain = $gpg -> decrypt($content);
var_dump($plain);

The result was: bool(false)

What I am doing wrong? I've tried different code and suggestions, but always ended up with bool(false).

Are these methods not compatible, do I have to a different application?

I appreciate every little help I could get. Thanks alot!

P.S. PHP is compiled with gnupg GPGme Version 1.4.2 Extension Version 1.3.3-dev

lufi
  • 610
  • 7
  • 29

1 Answers1

3

Problem solved. If anybody run into the same trouble, it's due to lag in the PHP Documentation:

string gnupg_decrypt ( resource $identifier , string $text )

If found the following comment in the comment section: As of gnupg version 2, it is not possible to pass a plain password any more. The parameter is simply ignored. Instead, a pinentry application will be launched in case of php running in cli mode. In cgi or apache mode, opening the key will fail. The simplest solution is to use keys without passwords.

So i've created a new key without password and everything works fine.

lufi
  • 610
  • 7
  • 29