Dear people on this list!
I've been 'playing' around with CryptoPP for quite some time now and have some problems decrypting a base64-encoded string I've encrypted before.
My code looks like this:
CryptoPP::RSAES_OAEP_SHA_Decryptor privkey(rng, 1024); CryptoPP::RSAES_OAEP_SHA_Encryptor pubkey(privkey);
// .....
// encrypt a string
CryptoPP::SecByteBlock sbbCipherText(pubkey.CiphertextLength(szClearText.size()));
pubkey.Encrypt(rng,
(byte const*)szClearText.data(),
szClearText.size(),
sbbCipherText.begin());std::string resultEncoded;
CryptoPP::Base64Encoder be3(new CryptoPP::StringSink(resultEncoded)); be3.Put(sbbCipherText.begin(), sbbCipherText.size()); std::cout << "Encrypted string: " << resultEncoded << std::endl;
// decrypt the string char szDecoded[1024];
CryptoPP::DecodingResult dresult = privkey.Decrypt(
rng,
(const byte*)sbbCipherText.data(),
sbbCipherText.size(),
(byte*)szDecoded);
szDecoded[dresult.messageLength] = '\0';
std::string szCleartextEncoded = std::string(szDecoded);std::cout << "Decrypted string: " << szCleartextEncoded << std::endl;
This works really fine. But what I would like to achieve is to use the base64 encoded string 'resultEncoded' as the input for decryption which I don't get going though trying hard.
Can someone please help me out on this?
Thanks in advance
and
kind regards,
Stephan
