Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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?
[usemodperl]: what the hell happened to the monastery?
usemodperl gets scolded by little old ladies on every dang post
[usemodperl]: did we get invaded by soy boys or what? it wasn't like this 20 years ago :-)
[usemodperl]: i can see the old tgimers hiding out on reddit! lol

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2018-06-24 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?