Problems with gpg in php


I have been working oon this problem non stop for the last two days and think I am going to go out of my mind.

From all the research I have done my coding should work, but alas it does not.

I am trying to get the values from a form encrypted, and then emailed.

I have tried may incarnations of various scripts posted on the web, and have tried altering them to fit my system, but to no avail.

From all my research I have scraped together the following:

$commandline = "echo $body | /usr/bin/gpg --homedir /home/username/.gnupg -a -e --batch --yes --no-secmem-warning -u SignerID -r RecipientID";
if ($debug==1) {
system($commandline);
} else {
exec($commandline, $encrypted, $error);
}

////////////////////
// Make the result array a string
////////////////////
if (is_array($encrypted)) {
$encrypted = implode($encrypted,"\n");
}

////////////////////
// Either output the debug info or mail it
////////////////////
if ($debug==1) {
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
} else {
if ($encrypted) {
mail($to,$subject,$encrypted,$from);
} else {
$notenc = 1;
echo $error;
}
}

The key here is the $commandline:

echo $body | /usr/bin/gpg --homedir /home/username/.gnupg -a -e --batch --yes --no-secmem-warning -u SignerID -r Recipient ID

If I enter this directly into my command line in my terminal I get a beautiful patch of encrypted info.

If I run it from the script I get an error of "2".

I am desparate for help.

Anything you can offer would be appreciated.

Posted On: Wednesday 24th of October 2012 12:32:49 AM Total Views:  347
View Complete with Replies

RELATED TOPICS OF PHP PROGRAMMING LANGUAGE