Hi,

Can anyone tell me why I get an error when I try to decrypt a file using Crypt::OpenPGP

The error is:
encrypt: datasize not multiple of blocksize (16 bytes) at C:/Perl/site/lib/Crypt/OpenPGP/CFB.pm line 59.

This happens whether I encrypt the file using my perl code (below) or using PGP v8.0. I can decrypt the file using PGP without any issues. I am pulling what little hair I have left out over this so hopefully someone can give me an easy (or hard) answer.

BEGIN CODE:

#!c:\perl\bin\perl.exe
use strict ("vars");
use dbi;
use Time::Local;
use Crypt::OpenPGP;
use Crypt::OpenPGP::KeyRing;
my ($ring,$secring);

my $args = @ARGV;
if ($args ne 3) {
    print "\nSyntax is pgpcl %1 %2 %3\n\n";
    print "%1 is either e or d. e = encrypt, d = decrypt\n";
    print "%2 is the input filename\n";
    print "%3 is the output filename\n";
    exit;
}
my $direction = lc($ARGV[0]);
if ($direction ne "e" && $direction ne "d") {
    print "\nSyntax requires either an e or d as the first parameter\n\n";
    exit;
}
my $infile = $ARGV[1];
my $outfile = $ARGV[2];
print "$infile - $outfile\n";
my $sid = "Temp Key";

$ring = Crypt::OpenPGP::KeyRing->new(Filename => 'C:\Data\CC3\Keyrings\wfbpub.pkr' ) or die "KeyRing error: ", Crypt::OpenPGP::KeyRing->errstr; $secring = Crypt::OpenPGP::KeyRing->new(Filename => 'C:\Data\CC3\Keyrings\wfbsec.skr' ) or die "KeyRing error: ", Crypt::OpenPGP::KeyRing->errstr;
my $uid = "Temp Key";
my $user = $ring->find_keyblock_by_uid($uid) or die "KeyFind error: ", Crypt::OpenPGP::KeyRing->errstr; my $signer = $ring->find_keyblock_by_uid($sid) or die "KeyFind error: ", Crypt::OpenPGP::KeyRing->errstr;
my $pgp = Crypt::OpenPGP->new(
                              Compat => 'PGP5',
                              PubRing => $ring,
                              SecRing => $secring,
                              ) or die Crypt::OpenPGP->errstr;

if ($direction eq "e") {
    print "Encrypt\n";

    my $cipher = $pgp->encrypt(
#                    Compat => 'PGP5',
                    Cipher => 'DES3',
                    Filename => $infile,
                    Recipients => $uid,
                    Armour => 1,
                    Compress => 'ZIP',
                   ) or die Crypt::OpenPGP->errstr;

    open (OUT,">$outfile");

    print OUT $cipher;

    close(OUT);
}
if ($direction eq "d") {
    print "Decrypt\n";
    my $encpass = $pgp->decrypt(
                               Filename => 'c:\data\cc3\keyrings\tpw.pgp',
                               Passphrase => 'password',
                               ) or die Crypt::OpenPGP->errstr;
    print "$encpass";
}

END CODE:

Thanks for any help,

Tony


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.362 / Virus Database: 267.12.8/161 - Release Date: 11/3/2005


_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to