Bleeding for an example of how to use Crypt_GPG
| From: | Everett Griffiths | Date: | Fri, 16 May 2008 00:43:41 +0000 |
| Subject: | Bleeding for an example of how to use Crypt_GPG | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-28930@lists.php.net to get a copy of this message | ||
This is driving me insane. There doesn't appear to be a single actual
line of code anywhere in the PEAR documentation of the Crypt_GPG.
Can someone give me a simple example of how to actually use this module?
We've got some pretty senior people here who are equally baffled by
this.
I'm trying this via a simple test script, test.php:
<?php
require_once 'Crypt/GPG.php';
$crypt = Crypt_GPG::factory();
$key_id='encryption@example.com';
$unencrypted_data = 'Testing...';
$encrypted_data = $crypt->encrypt($key_id, $unencrypted_data,
false); // The false gives us the encryption as a binary string
echo $encrypted_data;
?>
At one point, this actually worked. Now I have no idea why it's not
working... I'm getting this error:
PHP Fatal error: Uncaught Crypt_GPG_Exception: Unknown error encrypting
data. in
/home/egriffiths/src/oversee/dev/RT-29437_prepared_statements_on_low/tes
t.php on line 12
#0 /full/path/to/test.php(12):
Crypt_GPG_Driver_Php->encrypt('marketing_servi...', 'Testing...', false)
#1 {main}
thrown in /usr/share/pear/Crypt/GPG/Driver/Php.php on line 890
The key I created DOES work via the command line via something like
this:
sudo gpg -r marketing_services_encryption@example.com --encrypt test.txt
Where "test.txt" contains a simple text message; then a test.txt.gpg
file is created containing the encrypted version.
Can someone help me out? Thanks.
Everett Griffiths