Keep It Simple, Stupid | |
PerlMonks |
Re: Re: Re: Eating RAM problemby graff (Chancellor) |
on Aug 02, 2002 at 01:43 UTC ( [id://186981]=note: print w/replies, xml ) | Need Help?? |
You said:
I am working on an encryption system where each ASCII
char is assigned a certain number of bits, so for example,
if the text to be encrypted is 1000 bytes, then after
encryption that text will be converted
to 36000 bytes consisting of just 0's and 1's.
Is it the case that the encryption system requires access to the entire data stream in order to work at all? If encrypting, say, 10 sets of 100 bytes (producing 10 sets of 3600 bytes) works as well as cranking a lump of 1000 bytes into 36000, then you should just read, process and output a small portion of data at a time, rather than trying to hold an entire file -- with massive amounts of wasted bits -- in memory at one time. Apart from that -- I'm sorry but... -- if memory consumption is an issue, and forcing some particular method of bit padding is a requirement, I'd use C rather than Perl. update: Maybe what you want is sysread, to bring a stated number of bytes into an input scalar variable; e.g.:
In Section
Seekers of Perl Wisdom
|
|