Hi Folks,

I have a job that takes in an encrypted file and decrypts it using
Crypt::GPG.

<code>
 for my $encrypted_file (@files) {
         
         open(CIPHERTXT, $encrypted_file) or croak "Can't open
encrypted_file: $encrypted_file\n";
         my @ciphertxt = <CIPHERTXT>;

         my($cleartxt, $signature) = $gpg -> decrypt([EMAIL PROTECTED]); 

         # File names must have a ".extension" on them if they're
encrypted
         # we will strip off the last "dot" and everything after it to
name the 
         # clear text file
         my $filename = (split /\.\w+$/, $encrypted_file)[0]; 

         open(CLEARTXT, ">", "$filename") or croak "Can't write to
$filename: $!\n";
         print CLEARTXT $cleartxt or croak "Can't print cleartext:
$!\n";
         close CLEARTXT or croak "Can't close <CLEARTXT>?\n";

         push @processed_files, $filename or croak "Can't create list of
decrypted files!\n";
}
</code>

Mostly, this works as I expect, but once in a blue moon we get a
ciphertext that produces a 0 byte cleartext file when run
through the above code. When I decrypt the file manually (gpg --decrypt
<filename> > clear.txt ) I get a good (readable) cleartext file.

Anyone have any ideas about how to fix this?
Any help is appreciated!

richf

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to