I found examples on the wiki about how to use crypto++ to compress and decompress files using Crypto++'s Gzip algorithm. But all examples I found process the whole file at once. Imagine I need to compress a 1GB+ file. Maybe now we have computers with large amounts of memory, but this is completely out of the question.
What I'm trying to do is to process a file using buffers to load small chunks of data trough a File Source. This is what I got so far: ofstream output; //Compression output.open("TEST/out.a", fstream::binary); int got,ncomp,diff = 0; char* ib = new char [BUFSIZE]; char* ob = new char [BUFSIZE]; for(int x = 0; x < BUFSIZE; x++) { ib[x] |= 0x0; ob[x] |= 0x0; } FileSource fsr("TEST/a.jpg", false, new Gzip(new ArraySink((byte*)ob , BUFSIZE))); while(!fsr.SourceExhausted()) { got = fsr.Pump(BUFSIZE); fsr.Flush(false); cout << "Pumped " << got << " bytes" << endl; if(got == 0) break; output.write(ob, got); } output.close(); //Decompression for(int x = 0; x < BUFSIZE; x++) { ib[x] |= 0x0; ob[x] |= 0x0; } cout << "Decript" << endl; output.open("TEST/test.jpg", fstream::binary); FileSource fir("TEST/out.a", false, new Gunzip(new ArraySink((byte*) ib, BUFSIZE))); while(!fir.SourceExhausted()) { got = fir.Pump(BUFSIZE); fir.Flush(false); cout << "Pumped " << got << " bytes" << endl; if(got == 0) break; output.write(ib, got); } output.close(); delete[] ib, ob; cout << "Done" << endl; I have several problems with this code. First of all, the file is not processed entirely. Instead, one portion is processed, and then it repeats trough the whole file. This is obviously not what I want to do, I need to process the whole file, but in small chunks. Also, SourceExhausted() doesnt return true once it reaches the end of the file (thus why there is a break in this code when there shouldn't be needed). I know there are ways to do this directly without the need of a buffer, but I need to pass it trough memory because I need to implement this somewhere else, and I need all this data to be processed first in memory, so I cant use a FileSink. -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to cryptopp-users-unsubscr...@googlegroups.com. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- You received this message because you are subscribed to the Google Groups "Crypto++ Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.