Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

GPG decryption

by chinesebob (Initiate)
on Jan 22, 2003 at 19: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 (Priest) on Jan 22, 2003 at 21: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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-05-26 13:10 GMT
Find Nodes?
    Voting Booth?