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

Most multitudinous monks,

$gpg->encrypt() works as always but $gpg->verify() is broken for me in Crypt::GPG v1.52

The same code which worked in v1.42-
my $gpg = new Crypt::GPG; $gpg->gpgbin('/usr/bin/gpg'); $gpg->secretkey('0x2F7B366A'); $gpg->passphrase('test'); $gpg->debug(1); # Works my @encrypted = $gpg->encrypt('This is a test', 'devnull@codefix.net') +; # Breaks my ($cleartxt, $signature) = $gpg->verify(\@encrypted); print "$signature\n\n$cleartxt\n";
now throws:
Can't use string ("0x2F7B366A") as a HASH ref while "strict refs" in u +se at /usr/lib/perl5/vendor_perl/5.8.6/Crypt/GPG.pm line 176.
Am I doing something wrong or is 1.52 broken?

Replies are listed 'Best First'.
Re: Crypt::GPG error
by kwaping (Priest) on Aug 30, 2005 at 15:28 UTC
    I think 1.52 is borked. Looking at the source of the module, the author is pretty good about checking whether $self->{SECRETKEY} is a reference or not. However, on line 176, the author doesn't check and just uses it as a reference:
    if ($2 eq $self->{SECRETKEY}->{ID}) {
    That seems to be what produced your error message. A simple fix would be to change line 176 to this:
    if ($2 eq (ref($self->{SECRETKEY}) ? $self->{SECRETKEY}->{ID} : $self- +>{SECRETKEY}) ) {
      An email to the author of the module may be in order with the fix. :)

      Jason L. Froebe

      Team Sybase member

      No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

        Good idea, will do.
      This fixes the error, unfortunately the value returned by $gpg->verify() is now always null! I think 1.52 is seriously borked.

      While I'm certain this will continue to be an edifying experience, my immediate objective is to get my srcript running again; is there a way to go back to 1.42?
        Oops- forgot to sign in. ;)