What am I doing wrong?   I encrypt a tar file and immediatly decrypt it (in a 
different function, however) and it is a totally borked file upon decryption.  
I've basically copy-pasted the example from Crypt:CBC.  The only clue I have 
is this warning:

Use of uninitialized value in pack at 
/usr/local/lib/perl5/site_perl/5.8.0/Crypt/CBC.pm line 213, <STDIN> line 3.

using this:

----------- encryption ------------
 $cipher = Crypt::CBC->new( {'key'             => $password,
                              'cipher'          => 'Blowfish',
                              'padding'         => 'standard',
                           });

open(in, "$ws/$$.new/$$.tar") || die;
open(out, ">$newname") || die;

$cipher->start('encrypting');

   while (read(in, $buf, 1024 ) )
      {
      print out $cipher->crypt($buf);
      }

print out $cipher->finish;

close(in);
close(out);

-------------------------- decryption --------------------

$cipher = Crypt::CBC->new( {'key'             => $password,
                               'cipher'          => 'Blowfish',
                               'padding'         => 'standard',
                              });

open (in, $cryptfile) || die;
open (out, ">$workspace/$$") || die;

$cipher->start('decrypting');

while (read(in, $buf, 1024 ) )
      {
      print out $cipher->decrypt($buf);
      }

print out $cipher->finish;
close(in);
close(out);


The warning that is given comes from the "finish" call while decrypting in the 
Crypt:CBC module:

sub finish (\$) {
    my $self = shift;
    my $bs = $self->{'blocksize'};
    my $block = $self->{'buffer'};

    $self->{civ} ||= '';

    my $result;
    if ($self->{'decrypt'}) { #decrypting
        $block = pack("a$bs",$block); # pad and truncate to block size

*snip*

I just don't see what (if anything) I'm doing wrong.  Since the comment 
appears to be talking about padding, I've tried a few different padding 
options with crypt:cbc, all with the same result.

-Phil

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to