in reply to Favorite PGP module for web-to-email forms?

Thanks for the tips on GnuPG. Now I've read the docs and I have a followup question on how to use it. :)
  It looks like it usually works with either files or STDIN and STDOUT. What I'd like to do is to pass in a scalar variable to encrypt and get back the results in another scalar variable. Does someone have an example of how to work with STDIN and STDOUT to do this? Or, asked another way, what do you find is the easiest way to pass text back and forth from GnuPG.pm?
  • Comment on Example GnuPG code (working with STDOUT AND STDIN)

Replies are listed 'Best First'.
GnuPG::Tie.pm does this
by markjugg (Curate) on Aug 17, 2000 at 00:35 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