I am running a lot of algorithms from Crypto++. I am Encrypting, then decrypting like this:
int main(int argc, char* argv[]) {
AutoSeededRandomPool prng_blowfish;
SecByteBlock key_blowfish(Blowfish::DEFAULT_KEYLENGTH);
prng_blowfish.GenerateBlock( key_blowfish, key_blowfish.size() );
byte iv_blowfish[ Blowfish::BLOCKSIZE ];
prng_blowfish.GenerateBlock( iv_blowfish, sizeof(iv_blowfish) );
string ifilename = "sample_files/1MB.jpg";
string cipher = "1MB.enc";
string rfilename = "r1MB.jpg";
try {
EAX< Blowfish >::Encryption e_blowfish;
e_blowfish.SetKeyWithIV( key_blowfish, key_blowfish.size(), iv_blowfish, sizeof(iv_blowfish) );
std::ifstream ifile(ifilename.c_str(), ios::binary);
std::ifstream::pos_type size = ifile.seekg(0, std::ios_base::end).tellg();
ifile.seekg(0, std::ios_base::beg);
FileSource fs1( ifilename.c_str(), true, new AuthenticatedEncryptionFilter( e_blowfish, new FileSink(cipher.c_str()) ) );
EAX< Blowfish >::Decryption d_blowfish;
d_blowfish.SetKeyWithIV( key_blowfish, key_blowfish.size(), iv_blowfish, sizeof(iv_blowfish) );
FileSource fs2( cipher.c_str(), true, new AuthenticatedDecryptionFilter( d_blowfish, new StringSink( rfilename ), AuthenticatedDecryptionFilter::THROW_EXCEPTION ) );
} catch (const Exception& ex) {
cerr << ex.what() << endl;
}
return 0;
}
I need to make sure that everything is working properly. I would like to compare the file that is being read in from before it is encrypted to the file after it has been decrypted so that I know everything is working properly. Can somebody create an example of how I would be able to do this?