Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

GPG decryption

by chinesebob (Initiate)
on Jan 22, 2003 at 14:53 UTC ( #229117=perlquestion: print w/replies, xml ) Need Help??

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

I am attempting to decrypt a file using a specific key and that key's password. I've tried several different modules but all of them fail. This is what I've got.
#!/usr/bin/perl -w use strict; use warnings; use GPG; my($passphrase,$key_id) = ("passphrase","KeyName"); my $gpg= new GPG(homedir=>"/home/chinesebob/.gnupg"); die $gpg->error() if $gpg->error(); my $file=$gpg->decrypt_verify($passphrase,"try.pgp");

Replies are listed 'Best First'.
Re: GPG decryption
by Paladin (Vicar) on Jan 22, 2003 at 16:34 UTC
    According to the docs for GPG, decrypt_verify() and friends take the actual text as the second argument, not a file name. Try:
    ... open GPGFILE, "try.gpg" or die "Couldn't open try.gpg: $!"; my $text = do {local $/; <GPGFILE>}; close GPGFILE; my $file=$gpg->decrypt_verify($passphrase,$text); print $file->{text}; ...
      Instead of using the module I tried the
      system(gpg ......);
      and it worked. Go figure. thank you anyways.
      I was racking my brain trying to work out why:


      wasn't working for $text

      The GPG pod wasn't clear to me on this issue, thanks for clearing it up for us Paladin :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://229117]
Approved by gjb
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2020-01-20 08:18 GMT
Find Nodes?
    Voting Booth?