I'm learning Crypto++ library. I've read lot of examples but didn't find how to encrypt/decrypt plain text message when the program has access to public key only, when the program not generates the keys.
CryptoPP::RSA::PublicKey pubKey;
pubKey.Load(CryptoPP::StringSource(SSL_PUB_KEY, true, new CryptoPP::Base64Decoder()).Ref());
CryptoPP::RSAES_OAEP_SHA_Encryptor e(pubKey);
But what to do after that?
I've get how to do it. I missundertood what RandonGenerator is and I thought that I have to get it from a key.
After that I do following:
CryptoPP::AutoSeededRandomPool rng;
string cipher;
CryptoPP::StringSource ss1(stringToEncrypt, true, new CryptoPP::PK_EncryptorFilter(rng, e, new CryptoPP::StringSink(cipher)));
now we have encrypted data in cipher