#define CRYPTOPP_DEFAULT_NO_DLL #include "dll.h" #include "blowfish.h" USING_NAMESPACE(CryptoPP) USING_NAMESPACE(std) void Blowfish_Encrypt(SecByteBlock hexKey, SecByteBlock hexIV, const char *infile, const char *outfile); void Blowfish_Decrypt(SecByteBlock hexKey, SecByteBlock hexIV, const char *infile, const char *outfile); int main() { // Generate a random key AutoSeededRandomPool rnd; SecByteBlock key(0x00, Blowfish::DEFAULT_KEYLENGTH); rnd.GenerateBlock(key, key.size()); // Generate a random IV SecByteBlock iv(0x00, Blowfish::BLOCKSIZE); rnd.GenerateBlock(iv, Blowfish::BLOCKSIZE); Blowfish_Encrypt(key, iv, "kep.jpg", "crypt"); Blowfish_Decrypt(key, iv, "crypt", "kepNew.jpg"); return 0; } void Blowfish_Encrypt(SecByteBlock key, SecByteBlock iv, const char *infile, const char *outfile) { CBC_Mode::Encryption bf(key, key.size(), iv); FileSource(infile, true, new StreamTransformationFilter(bf, new FileSink(outfile))); } void Blowfish_Decrypt(SecByteBlock key, SecByteBlock iv, const char *infile, const char *outfile) { CBC_Mode::Decryption bf(key, key.size(), iv); FileSource(infile, true, new StreamTransformationFilter(bf, new FileSink(outfile))); }