I am intermediate with c++ but new to the pipeline paradigm and crypt o++
lib. I am trying to zip and unzip a file. I have been able to gzip the
file but when i try to unzip it to a filesink, the file is empty. The gzip
produces a file half the size as the original uncompressed file but gunzip
is giving me a file with nothing in it. I know I am doing something wrong
here. please help. Here is the code that don't work:
try{
std::ofstream
zippedOutFile("C:\\Somefolder\\testzipped",std::ios_base::trunc);
FileSink* zippedSink = new FileSink(zippedOutFile);
Gzip z(zippedSink);
z.Put((byte*)(unCompressedData.c_str()),unlength,true);
z.MessageEnd();
zippedOutFile.close();
std::ifstream
zippedIfstreamFile("C:\\Somefolder\\testzipped",std::ios_base::in);
FileSource zippedSource(zippedIfstreamFile,true);
std::ofstream
unzippedFile("C:\\Somefolder\\\testunzipped",std::ios_base::out);
FileSink* unzippedSink = new FileSink(unzippedFile);
Gunzip uz(unzippedSink);
lword maxZipData = zippedSource.TotalBytesRetrievable();
byte* zipData = new byte[maxZipData+1];
memset(zipData,'\0',sizeof(zipData));
size_t left = zippedSource.Get(zipData,maxZipData);
if(left > 0){
MessageBox(NULL,_T("left > 0"),_T(""),MB_OK);
}
uz.Put(zipData,sizeof(zipData),true);
lword maxUnZippData = uz.TotalBytesRetrievable();
byte* unZippedData = new byte[maxUnZippData+1];
memset(unZippedData,'\0',sizeof(unZippedData));
uz.Get(unZippedData,maxUnZippData);
MessageBox(NULL,CString(unZippedData),_T(""),MB_OK);
unzippedFile.close();
zippedIfstreamFile.close();
}catch(Exception e){
MessageBox(NULL,CString(e.what()),_T(""),MB_OK);
return -1;
}
I am new to crypto++ lib and the pipeline design please help.
--
View this message in context:
http://old.nabble.com/crytpo%2B%2B-gunzip-a-file-that-i-compressed-with-crykltp%2B%2B-gzip-tp34992733p34992733.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.
--
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.