I am trying to encrypt and decrypt an image file with ElGamal in C++. It has to use ElGamal encryption. I want to save both the encrypted file and recovered file. I am using Crypto++ libraries for the encryption/decryption part. Here is what I have so far.
AutoSeededRandomPool prng;
ElGamal::Decryptor decryptor;
decryptor.AccessKey().GenerateRandomWithKeySize(prng, 2048);
const ElGamalKeys::PrivateKey& privateKey = decryptor.AccessKey();
ElGamal::Encryptor encryptor(decryptor);
const PublicKey& publicKey = encryptor.AccessKey();
string ofilename = "test.bmp";
string efilename = "test.enc";
string rfilename = "test-recovered.bmp";
FileSource fs1(ofilename.c_str(), true, encryptor.CreateEncryptionFilter(encryptor.Encrypt, new FileSink(efilename.c_str())));
FileSource fs2(efilename.c_str(), true, decryptor.CreateDecryptionFilter(decryptor.Decrypt, new FileSink(rfilename.c_str())));
I am stuck at the encryption and decryption part. Any help would be greatly appreciated!