Crypt::OpenPGP problem

G

Gilian

Hello,

I hope somebody can help me with this problem.

I have a perl-script that creates file, that need to be encrypted.
I use the Crypt::OpenPGP module to make the encryption done. The only
thing I want to do is 'conventional encryption', which means I don't
want to use keys, but I want to encrypt it with a password.

The script looks like this:
#!/usr/bin/perl

use Crypt::OpenPGP;

my $pgp = Crypt::OpenPGP->new();

$file = 'file.txt';
$phrase = 'test123456';

$encrypted = $pgp->encrypt(
Compat => 'PGP5', # <== in PGP2 it works fine!
Filename => $file,
Passphrase => $phrase,
) or die "can not encrypt ",$pgp->errstr;

print "$encrypted\n";

open (OUTFILE, "> $file.pgp");
print OUTFILE "$encrypted";
close (OUTFILE);


When I do this with the encryption in PGP2 there is no proble, when I
try to encrypt in PGP5 I get the following response:
Can't call method "keysize" on an undefined value at
/usr/lib/perl5/site_perl/5.8.3/Crypt/OpenPGP.pm line 525.

Can somebody tell me what the problem is, or rather give me a solution
to the problem.

Thanks in advance.

Regards,
Gilian.
 
S

Sisyphus

Gilian said:
Hello,

I hope somebody can help me with this problem.

I have a perl-script that creates file, that need to be encrypted.
I use the Crypt::OpenPGP module to make the encryption done. The only
thing I want to do is 'conventional encryption', which means I don't
want to use keys, but I want to encrypt it with a password.

The script looks like this:
#!/usr/bin/perl

use Crypt::OpenPGP;

my $pgp = Crypt::OpenPGP->new();

$file = 'file.txt';
$phrase = 'test123456';

$encrypted = $pgp->encrypt(
Compat => 'PGP5', # <== in PGP2 it works fine!
Filename => $file,
Passphrase => $phrase,
) or die "can not encrypt ",$pgp->errstr;

print "$encrypted\n";

open (OUTFILE, "> $file.pgp");
print OUTFILE "$encrypted";
close (OUTFILE);


When I do this with the encryption in PGP2 there is no proble, when I
try to encrypt in PGP5 I get the following response:
Can't call method "keysize" on an undefined value at
/usr/lib/perl5/site_perl/5.8.3/Crypt/OpenPGP.pm line 525.

Can somebody tell me what the problem is, or rather give me a solution
to the problem.

The script you supplied works fine for me on Linux (Mandrake-9.1), perl
5.8.3. I'm using version 1.03 of Crypt-OpenPGP, which is the latest
available on CPAN. If you're using an older version then you probably
need only to update.

Otherwise, 'use warnings;' at the start of your script. That may provide
some useful output.

Also you should check that the 'open' and 'close' calls succeeded
(though that has nothing to do with the problem you are experiencing).

Cheers,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top