I am trying to use OpenPGP to encrypt a file so I can transmit using FTP. The program below does process and it outputs data but when they decrypt it the first 80 characters are decrypted and the rest of the file is still encrypted and not readable. Does anybody have any ideas as to what I might be doing wrong?
Thanks in advance for the help.
#!c:\perl\bin\perl.exe
use strict;
use warnings;
use Crypt::OpenPGP;
my $ring = Crypt::OpenPGP::KeyRing->new(
Data => qq^-----BEGIN PGP PUBLIC KEY BLOCK-----
“””this is where I have my public key”””
-----END PGP PUBLIC KEY BLOCK-----^ );
my $datafile = "test";
open( INFILE, "< $datafile".".txt" )
or die "Could not open txt file - $!";
my $plaintext = <INFILE>;
close INFILE;
$ring->read;
my $kb = $ring->find_keyblock_by_index(0);
my $cert = $kb->encrypting_key;
my $pgp = Crypt::OpenPGP->new;
my $ct = $pgp->encrypt( Key => $cert, Data => $plaintext )
or die "ERROR: " . $pgp->errstr;
open( OUTFILE, "> $datafile".".pgp" )
or die "Could not open file for encrypted data - $!";
print OUTFILE $ct;
close OUTFILE;
Thanks in advance for the help.
#!c:\perl\bin\perl.exe
use strict;
use warnings;
use Crypt::OpenPGP;
my $ring = Crypt::OpenPGP::KeyRing->new(
Data => qq^-----BEGIN PGP PUBLIC KEY BLOCK-----
“””this is where I have my public key”””
-----END PGP PUBLIC KEY BLOCK-----^ );
my $datafile = "test";
open( INFILE, "< $datafile".".txt" )
or die "Could not open txt file - $!";
my $plaintext = <INFILE>;
close INFILE;
$ring->read;
my $kb = $ring->find_keyblock_by_index(0);
my $cert = $kb->encrypting_key;
my $pgp = Crypt::OpenPGP->new;
my $ct = $pgp->encrypt( Key => $cert, Data => $plaintext )
or die "ERROR: " . $pgp->errstr;
open( OUTFILE, "> $datafile".".pgp" )
or die "Could not open file for encrypted data - $!";
print OUTFILE $ct;
close OUTFILE;