PDA

View Full Version : gnuPG PHP Configuration



mcunn
08-04-2009, 10:07 AM
I'm hitting my head against the wall trying to build a working gnuPG install. Im trying to use the following sample code which returns an error:

Class 'gnupg' not found in /home7/[Username]/public_html/synergytest/script.php

I've installed GNUPG via cpanel and have a valid key setup. I know I'm missing something stupid with the path but I'm on 4+ hours staring at the thing.

Thanks!

Michael



---
$CONFIG['gnupg_home'] = '/home/[myusername]/.gnupg';
$CONFIG['gnupg_fingerprint'] = '[myfingerprint';

$data = 'this is some confidential information';

$gpg = new gnupg();
putenv("GNUPGHOME={$CONFIG['gnupg_home']}");
$gpg->seterrormode(GNUPG_ERROR_SILENT);
$gpg->addencryptkey($CONFIG['gnupg_fingerprint']);
$encrypted = $this->gpg->encrypt($data);
echo "Encrypted text: \n<pre>$encrypted</pre>\n";


// Then use something like this to decrypt the data.
$passphrase = 'Your_secret_passphrase';
$gpg->adddecryptkey($CONFIG['gnugp_fingerprint'], $passphrase);
$decrypted = $gpg->decrypt($encrypted);

echo "Decrypted text: $decrypted";
?>
---

farcaster
08-04-2009, 10:43 AM
could it be as easy as a missing/misplaced closing bracket(s) in the second line?

$CONFIG['gnupg_fingerprint'] = '[myfingerprint';

S/B
$CONFIG['gnupg_fingerprint'] = ['myfingerprint'];

mcunn
08-04-2009, 11:21 AM
Sorry the brackets were added to show that it was a placeholder. They dont exist in the actual code.

Ammiddeon
08-20-2009, 04:54 PM
If its givving you an error "2" then it cant connect to your database

you will need to edit the configuration.php and make sure that the database, user name, password, live site location, absolute path etc are all correct