Given a "string filename", how can I get the Adler32 checksum using the C++ Crypto++ library. I am a little confused about using their Source and Sink system.
Below I have the skeleton of the code that does MD5, but I can't seem to find any examples or tutorials on the Adler32 usage.
string filename = "/tmp/data.txt"
string file_adler32_digest;
string file_md5_digest;
MD5 hashMD5;
FileSource fs( filename.c_str(),
true,
new HashFilter( hashMD5,
new HexEncoder( new StringSink( file_md5_digest ) ) ) );
/* Confusion begins here */
//how do I do the adler32 ?
/* Confusion ends here */
cout << file_adler32_digest << endl
<< file_md5_digest << endl;
Good samples and sample code here http://www.cryptopp.com/wiki/Category:Sample for all the Crypto++ (except for the Adler32 stuff I want)
If you follow this http://www.cryptopp.com/wiki/HashFilter, you have to change hashMD5 for hashAdler32, and file_md5_digest for file_adler32_digest
Adler32 hashAdler32;
FileSource( filename.c_str(),
true,
new HashFilter( hashAdler32,
new HexEncoder( new StringSink( file_adler32_digest ) ) ) );
After this file_adler32_digest
should contain the desired hash.