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

Hi, I am new to PGP and trying to improve in perl too. Using perl script I am trying to decrypt a file and place it in a different directory. What command should I be using or can someone guide me to all the commands for PGP Version 6.5.8 for windows that I can use in my perl script. Does it looks something like below:

pgp --decrypt --user $pgpkey $filename --output $outputfilename --overwrite

I'll really appreciate if can get the right commands that I can plug into my perl script. I am using PGP Freeware Version 6.5.8 for windows. Thanks
  • Comment on PGP Version 6.5.8 command to use to decrypt a file using perl script
  • Download Code

Replies are listed 'Best First'.
Re: PGP Version 6.5.8 command to use to decrypt a file using perl script
by Joost (Canon) on Feb 25, 2005 at 22:55 UTC
Re: PGP Version 6.5.8 command to use to decrypt a file using perl script
by cbrandtbuffalo (Deacon) on Feb 26, 2005 at 20:32 UTC
    When I'm scripting some process, I usually work it out manually first so I know each step works. So before trying your pgp commands in the script, work out how to decrypt the file just by typing in the command. Once you have that down, putting it into the Perl script is easy.

    As mentioned above, the best resource for getting the details for PGP is the PGP documentation.

    One last thing; if you consider gpg you may have trouble with decrypting files sent to you by someone using PGP if they use the IDEA encryption algorithm. I think this is the default algorithm for PGP, and it has some licensing requirements. If you can contact the person encrypting the files on the other end, you can ask them to use a different algorithm. For most people, the actual algorithm won't matter and there are fully open source ones available.

Re: PGP Version 6.5.8 command to use to decrypt a file using perl script
by meredith (Friar) on Feb 26, 2005 at 05:26 UTC

    In addition to Joost's comment, I'd like to point out that pgp will look at the available secret keys on the keyring and tell you which one (if any) should be used to decrypt. Also, I'm not clear if the encrypted filename can be inserted in the middle like that. I would use something more like the following:

    pgp --decrypt --output $outputfilename --overwrite $filename

    I'm not sure how far along your perl skills are, but two modules on CPAN that you might be interested in (if you know how to use them) are Crypt::OpenPGP and Crypt::GPG. Crypt::GPG uses the gpg command to do its work, while Crypt::OpenPGP handles all the work of pgp/gpg on its own. There may be one that's made to work with the free PGP that you're using, too.

    Update: Check out Crypt::PGPSimple, too.

    mhoward - at - hattmoward.org