For others having the same difficulty, I was able to solve the problem
with the snippets below. It seems in the RSADecryptString function,
the ordering of the last function was wrong.

string RSAEncryptString(const string publicKey, const char *seed,
const string message)
{
    StringSource pubString(publicKey, true, new HexDecoder);
    RSAES_OAEP_SHA_Encryptor pub(pubString);
    AutoSeededRandomPool randPool;
    std::string result;
    StringSource(message, true, new HexEncoder(new
PK_EncryptorFilter(randPool, pub, new StringSink(result))));
    return result;
}

string RSADecryptString(const string privateKey, const string
ciphertext)
{
    StringSource privString(privateKey, true, new HexDecoder);
    RSAES_OAEP_SHA_Decryptor priv(privString);
    AutoSeededRandomPool randPool;
    std::string result;
    StringSource(ciphertext, true,new
PK_DecryptorFilter(randPool,priv, new HexDecoder(new
StringSink(result))));
    return result;
}

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to