zentara has asked for the wisdom of the Perl Monks concerning the following question:
#!/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__
###############################################
and the corruption in the decoded output
I figure it is probably something simple, but I can't figure out what it is.#### ........... ........... while (read(INF1,my $buf, 1024 ) ) { print OUTF1 $cipher->decrypt($buf); } pri.<d^KOb.Ï->finish; close(INF1); close(OUTF1);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Crypt::CBC with Blowfish problem
by tirwhan (Abbot) on Jan 06, 2006 at 15:23 UTC | |
by zentara (Cardinal) on Jan 06, 2006 at 15:46 UTC | |
|
Re: Crypt::CBC with Blowfish problem
by borisz (Canon) on Jan 06, 2006 at 15:45 UTC | |
|
Re: Crypt::CBC with Blowfish problem
by zentara (Cardinal) on Jan 06, 2006 at 15:05 UTC | |
|
Re: Crypt::CBC with Blowfish problem
by reneeb (Chaplain) on Jan 07, 2006 at 07:42 UTC |