Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

GPG decryption

by chinesebob (Initiate)
on Jan 22, 2003 at 19:53 UTC ( [id://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 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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-16 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found