in reply to Example GnuPG code (working with STDOUT AND STDIN)
in thread Favorite PGP module for web-to-email forms?

To answer my own question, I just noticed that GnuPG::Tie.pm does what I want. There is example code here:

http://search.cpan.org/doc/FRAJULAC/GnuPG-0.07/GnuPG/Tie.pm

Replies are listed 'Best First'.
GnuPG::Tie::Encrypt failing
by markjugg (Curate) on Aug 19, 2000 at 00:28 UTC
    ..except the example code is failing for me. Here's what I have so far. It's dying when I try to read $ciphertext back from the filehandle. Can you offer suggestions or example code? Thanks! -mark
    sub encrypt_text { use GnuPG::Tie::Encrypt; tie *CIPHER, 'GnuPG::Tie::Encrypt', armor => 1, recipient => $PUBL +IC_KEY_USER_ID || die; print CIPHER shift || die; local $/ = undef; my $ciphertext = <CIPHER> || croak "died here: $!"; close CIPHER; untie *CIPHER; return $ciphertext; }
      Really random guess. Did you successfully "make test" when you installed GnuPG::Tie::Encrypt? I just tried installing and it failed on the test because I didn't have gpg in my path...
      The author was able to clue me in to the issue here. I think it was a "documentation bug". :) Adding this to my options fixed it:

      homedir => /path/to/.gnupg

      also adding: trace => 1 produced some useful debugging output.

      This was fixed for me by adding this to the hash used to tie the variable:
      homedir => "$HOME_DIR/.gnupg"
      However, with version 0.07 there is a problem that the author has confirmed that causes a connection to a Postgres database through DBI to be disconnected when this encryption happens. Very Weird. -mark