Re: seeming failure with a specific word
[email protected] (zentara) Fri, 06 Jan 2006 09:20:38 -0500
| Newsgroups | perl.crypto |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 05 Jan 2006 21:54:02 -0500, [email protected] (Marty Landman) wrote: >I'm trying to fix a bug in my application which encrypts using the >following -- only the $key and 'iv' have been changed : >The problem only seems to crop up when the value Neil is used afaik. Is my >initialization hosed, so that this kind of thing is likely to happen? I >notice from the CPAN writeup > >Yuck, what a mess. This site's in production and my client's just thrilled >to death by all this. Fortunately this was discovered before things got >into full swing, unfortunately it was discovered by the client, not me. :( Hi again, I was premature with my first post. ;-( I tried to test some sample scripts I had, which used to work, and lo-and-behold, I see corruption too. I am going to ask about this on perlmonks.org and see what the gurus say. This is the test script. Run it, and it should encrypt and decrypt itself. There is some corruption in the output where an -> gets changed to binary. #!/usr/bin/perl use warnings; use strict; use Crypt::CBC; ##----------- encryption ------------ my $cipher = Crypt::CBC->new( {'key' => 'secretfoo', 'cipher' => 'Blowfish', 'padding' => 'standard', }); open(INF, "< $0" ) || die; open(OUTF, ">$0.crypt") || die; $cipher->start('encrypting'); while (read(INF,my $buf, 1024 ) ) { print OUTF $cipher->crypt($buf); } print OUTF $cipher->finish; close(INF); close(OUTF); ##-------------------------- decryption -------------------- my $cipher1 = Crypt::CBC->new( {'key' => 'secretfoo', 'cipher' => 'Blowfish', 'padding' => 'standard', }); open (INF1, "< $0.crypt") || die; open (OUTF1, ">$0.decrypt") || die; $cipher->start('decrypting'); while (read(INF1,my $buf, 1024 ) ) { print OUTF1 $cipher->decrypt($buf); } print OUTF1 $cipher->finish; close(INF1); close(OUTF1); __END__ ############################################################## In my decrypted output, the following corruption occurs. It should be: print OUTF1 $cipher->decrypt($buf); } print OUTF1 $cipher->finish; close(INF1); close(OUTF1); I get decrypted: print OUTF1 $cipheröòcÑ } print OUTF1 $cipher->finish; close(INF1); close(OUTF1); ############################################################ -- I'm not really a human, but I play one on earth. http://zentara.net/japh.html