Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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");

Comment on GPG decryption
Download Code
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:

      $gpg->decrypt(pass,$text)

      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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2015-07-30 05:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls