FW: Crypt::CBC w/Crypt-DES

[email protected] (Toby Stuart) Wed, 23 Oct 2002 16:20:00 +1000
Newsgroups perl.crypto
Message-ID <[email protected]>

> -----Original Message-----
> From: Toby Stuart [mailto:[email protected]]
> Sent: Wednesday, October 23, 2002 3:54 PM
> To: '[email protected]'
> Subject: Crypt::CBC w/Crypt-DES
> 
> 
>  Hi All,
>  
>  I'm trying to encrypt/decrypt a text file using Crypt::CBC with DES.
>  
>  The encryption works fine but the decryption seems to yield 
>  only the first
>  few bytes of the original text.  I'm sure i'm missing 
>  something simple.
>  
>  Any help appreciated.
>  
>  Example follows:
>  
>  <enc.pl>
>  use strict;
>  use Crypt::CBC;
>  
>  my $key = pack "H16", "1122334455667788";
>  my $cipher = new Crypt::CBC ($key, 'IDEA');
>  
>  my $in;
>  open(IN,'e:\some_largish_text_file') || die $!;
>  print $cipher->encrypt($in) while read(IN,$in,1024);
>  print $cipher->finish;
>  close(IN);
>  </enc.pl>
>  
>  
>  
>  <dec.pl>
>  use strict;
>  use Crypt::CBC;
>  
>  if (!@ARGV) { die "Usage: perl $0 encrypted_file > 
>  decrypted_output_file"; }
>  
>  my $key = pack "H16", "1122334455667788";
>  my $cipher = new Crypt::CBC ($key, 'IDEA');
>  
>  my $in;
>  open(IN,$ARGV[0]) || die $!;
>  print $cipher->decrypt($in) while read(IN,$in,1024);
>  print $cipher->finish;
>  close(IN);
>  </dec.pl>
> 
> -- 
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>