I thought there might be a way of reusing the existing code in Crypt::CBC, so I took a peek. Not only can code from Crypt::CBC be reused, Crypt::CBC already does what you want! The following encrypts:
use Crypt::CBC; my $cipher = Crypt::CBC->new(...); open(INFILE, '<', 'BIG_FILE.txt') or die("Unable to open input file: $!"); open(OUTFILE, '>', 'BIG_FILE.enc') or die("Unable to create output file: $!"); $cipher->start('encrypting'); while (read(INFILE, $buffer, 65536)) { print OUTFILE $cipher->crypt($buffer); } print OUTFILE $cipher->finish;
The following decrypts:
use Crypt::CBC; my $cipher = Crypt::CBC->new(...); open(INFILE, '<', 'BIG_FILE.enc') or die("Unable to open input file: $!"); open(OUTFILE, '>', 'BIG_FILE.txt') or die("Unable to create output file: $!"); $cipher->start('decrypting'); while (read(INFILE, $buffer, 65536)) { print OUTFILE $cipher->crypt($buffer); } print OUTFILE $cipher->finish;
In reply to Re: Fast parsing for cypher block chaining
by ikegami
in thread Fast parsing for cypher block chaining
by fluffyvoidwarrior
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |