Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Fast parsing for cypher block chaining

by ikegami (Pope)
on Feb 28, 2006 at 18:55 UTC ( #533460=note: print w/replies, xml ) Need Help??


in reply to Fast parsing for cypher block chaining

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://533460]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-11-21 22:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (312 votes). Check out past polls.

    Notices?