in reply to Crypt OpenPGP Brain twister

print "plaintext: $plaintext\n"

That seems to be the major stumbling block. I tried it, and it came back undef each time, "undef" meaning failure. So I put together this example from the docs.

First, we need to create a plaintext data packet object and serialize that object. Next, deserialize the object.

I used Crypt::OpenPGP::Plaintext.

#!/usr/bin/perl use strict; use warnings; use Crypt::OpenPGP::Plaintext; use Data::Dumper::Concise; my $data = 'foo bar'; my $file = '/root/Desktop/foo.txt'; my $pt = Crypt::OpenPGP::Plaintext->new( Data => $data, Filename => $file, Mode => 'b', ); binmode STDOUT, ':encoding(utf8)'; print Dumper(my $serialized = $pt->save); print Dumper($serialized = $pt->data);

Replies are listed 'Best First'.
Re^2: Crypt OpenPGP Brain twister
by Anonymous Monk on Jun 22, 2011 at 07:23 UTC
    Um, its the decrypt call that is failing
      jeteve or others: Did this ever get a resolution? I'm repeating the same error on the decode. What to do?

        I had a similar problem, and I have solved it downgrading from Crypt-OpenPGP-1.06 to Crypt-OpenPGP-1.04

        The reason for this is that version 1.06 uses Math::BigInt where 1.04 uses Math::Pari for big numbers

        When a private RSA key is extracted from the ring, the components are stored in Math::BigInt objects, and at some point it are used with a Crypt::RSA::Key::Private objects, that internally uses Math::Pari objects for the components

        When the Crypt::RSA::Key::Private::AUTOLOAD method is called for component creation with a Math::BigInt object reference as a parameter, it fails. The component is't updated, but no error is reported

        Later, when the private key is going to be used for decrypt, it fails because it doesn't have the private components

        Hope this help

        Sorry, I meant on the decrypt.
Re^2: Crypt OpenPGP Brain twister
by Anonymous Monk on Feb 02, 2014 at 18:30 UTC
    I've been struggling with this error myself.
    Problem is the keys generated by ->keygen were crap.
    My solution was to get some keys generated the "proper" way, and that worked perfectly.
      How do we generate the key in "proper" way?