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

Greetings oh wise ones. I have been using Crypt::OpenPGP for a while now to encrypt plain text and text files but now I want to expand upon that. The following code encrypts a txt file just fine but fails if the file is an exe or a zip file. Is Crypt::OpenPGP capable of doing this or am I barking up the wrong tree? As always any help is appreciated.
$pubringfile = "C:\\pgp\\public.gpg"; $destfile = "C:\\temp\\dest.gpg"; $srcfile = "c:\\temp\\source.zip"; use Crypt::OpenPGP; $pgp = Crypt::OpenPGP->new ( "PubRing" => $pubringfile #### Define path to public ring t +o be used for encryption ); unless($pgp){ my $err = join(" ", "\n\nCOULD NOT ENCRYPT DATA ", Crypt:: +OpenPGP->errstr, "\n\n"); &sndevent("1017", 1, $err); die; } my $ciphertext = $pgp->encrypt ( "Filename" => $srcfile, "Recipients" => 'myemail@hotmail.com', "Cipher" => 'DES3', "Armour" => 0 ); unless($ciphertext){ my $err = join(" ", "\n\nCOULD NOT ENCRYPT DATA ", Crypt:: +OpenPGP->errstr, "\n\n"); print "$err\n"; } open (FILEHANDLE,">$destfile"); print FILEHANDLE "$ciphertext"; close FILEHANDLE;

Replies are listed 'Best First'.
Re: Can Crypt::OpenPGP Encrypt exe or zip files
by blazar (Canon) on Feb 22, 2005 at 17:01 UTC
    Reasonable guess + hint: binmode

    (or use open()'s ':raw' layer)