GnuPG in PHP failing with error code 2

Peter Gillett peter@tallwomensclothing.com
Thu Aug 8 13:24:01 2002


> I'm writing a php script to encrypt
> some data into a file using
> GnuPG.
>
> Any help with this would be greatly
> appreciated!  This issue is
> holding up a major project I'm working on.
>

Frank,

here is a perl script I use that may be of
help....


$gpg_path = "good_path/gpg.exe";
$gpg_options = "--homedir
good_path/gpg --batch --no-version --no-tty --alwa
ys-trust -ear";
$gpg_public_key_user_id = "blah\@blah.com.au";

sub make_gpg_file {
  local($output_text, $output_file) = @_;
  local($gpg_output);

  $gpg_command =  "$gpg_path $gpg_options ";
  $gpg_command .= "$gpg_public_key_user_id ";
  $gpg_command .= ">$output_file";

  open (gpgCOMMAND, "|$gpg_command");
  print gpgCOMMAND $output_text;
  close (gpgCOMMAND);

  open(gpgOUTPUT, $output_file);

  while (<gpgOUTPUT>) {
    $gpg_output .= $_;
  }

  close (gpgOUTPUT);
  unlink($output_file);
  return($gpg_output);
1;


It takes $output_text, encrypts it to
$output_file,
then returns $output_file into $gpg_output,
then deletes $output_file. It is called from
a perl shopping cart script.

The only thing that it needs to work is for
trustdb.gpg
and random_seed to be read/write in homedir, while
pubring.gpg and secring.gpg can be read only in
homedir.
Pubring.gpg can be read only in homedir, and gpg
will create a zero byte length secring.gpg the
first
time it is run. This can also be set to read only.


hope this is of some use,
Peter