php gnupg get_key failed error
<p>I am trying to decrypt a simple message with PGP(gnupg) in PHP.
But I always get this error: <code>get_key failed</code>.
On stack-overflow I see many people with this problem but I can't fix it.
I followed this tutorial that includes how to set the permissions for the files: <a href="http://46dogs.blogspot.nl/2007/11/setting-up-gnupg-gpg-for-use-with-php.html" rel="nofollow">http://46dogs.blogspot.nl/2007/11/setting-up-gnupg-gpg-for-use-with-php.html</a></p>

<p>This is the script that I am using. My PGP key does not contain a phase phrase:</p>

<pre><code>&lt;?php
putenv("GNUPGHOME=/home/user/.gnupg/");
$gpg = new gnupg();
$gpg -&gt; addencryptkey("2ADA21BDC9C96556EA0758F04A935AE0010AE203");
$encrypted_text = $gpg -&gt; encrypt("just a test");
//echo $encrypted_text;

$gpg = new gnupg();
$gpg-&gt;seterrormode(gnupg::ERROR_EXCEPTION);
try{
$gpg -&gt; adddecryptkey("2ADA21BDC9C96556EA0758F04A935AE0010AE203","");
$decrypted_text = $gpg -&gt; decrypt($encrypted_text);
} catch (Exception $e) {
    echo $e;
}
echo $decrypted_text;
?&gt; 
</code></pre>

<p>The permissions of the files(pubring.gpg, trustdb.gpg and secring.gpg) are exactly the same as the tutorial(Only user changed to nginx).<br>
The encrypting part works. But decrypting doesn't work.</p>

<p>Does anyone know what is wrong?</p>

<p>I am running Centos and php5.</p>