fx has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I've been trying to get one of my Perl programs to encrypt some data with PGP. At first I tried to use PGP5.pm (I think) but that writes the unencrypted data to disk before encrypting. This may not be safe if someone is 'watching' that directory.

I then tried doing something like open PGP, "|/usr/local/bin/pgp -eaf ... >/tmp/$PROCESS.txt" so that I could print PGP $message and get the encryted result in a temporary file on the drive.

This works if ran from the command line. If I then try to turn this into a web page script things fail with Please enter some random text on your keyboard until you hear the beep: cannot open tty, using stdin in the error log.

Does anyone have any advice for encrypting data using PGP and Perl without writing the plaintext to disk first?

Thanks,

fx

Replies are listed 'Best First'.
Re: Accessing PGP from Perl without storing temporary files
by MZSanford (Curate) on Oct 18, 2001 at 15:47 UTC
    it appears pgp verifies you are using a terminal to prevent anything it considers fishy. I would sugest taking a look at the Crypt::OpenPGP module, as i believe it will do what you want.

    woo hoo, 200th post
    i had a memory leak once, and it ruined my favorite shirt.
Re: Accessing PGP from Perl without storing temporary files
by derby (Abbot) on Oct 18, 2001 at 19:36 UTC
    fx,
    Are you married to PGP? I ran into the same issues with GPG and found of the four or so competing GPG modules only GPG did it all in memory.
    -derby

      Thanks to MZSanford - I will have a look at that module.

      Derby, as long as the encrypted copy can be viewed on a Windows OS I'm not bothered.

      Thanks,

      fx