Hello,

I have two systems, one is running Python and one is running CryptoPP C++.

I create a common certificate that is .DER encoded. I am able to import the 
certificate into both systems. I use the certificate to encrypt and decrypt 
successfully on each system individually.

Then I generate an encrypted message with Crypto++ and send it to Python 
and try to decrypt and it gives an error that decryption failed.

Can you suggest any debugging steps ?

std::string encrypt_rsa(std::string message, CryptoPP::RSA::PublicKey key)
{

try{

message = b64encode(message);
CryptoPP::AutoSeededRandomPool rng;

CryptoPP::RSAES_OAEP_SHA_Encryptor encryptor(key);
std::string ciphertext;
CryptoPP::StringSource(message, true, new CryptoPP::PK_EncryptorFilter(rng, 
encryptor, new CryptoPP::StringSink(ciphertext)));
return ciphertext;
}
catch(...)
{
std::cout << "error encrypting RSA";
return "";
}
}

def encrypt_rsa(message, key):
    try:
        result = rsa.encrypt(base64.b64encode(message), key)
        return result
    except Exception as err:
        print("There was an error encryption RSA", err)
        return None

def decrypt_rsa(cipherbytes, key):
    try:
        base64_bytes = rsa.decrypt(cipherbytes, key)
        return base64.b64decode(base64_bytes)
    except Exception as err:
        print(err)
        return None

-- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cryptopp-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/bab2bb5d-048c-4857-a98e-fef8d32d18d6n%40googlegroups.com.

Reply via email to