I was encoding emails to be used with an external website's API using Python M2Crypto's RSA with PKCS1 padding. When using unicode, the encoded emails returned no results from the API, but when I used str(unicode_email), I received the correct information.
I was under the impression that both unicode and byte representations of a string should have worked in this case. Does anyone know why the unicode fails?
Code for reference:
from M2Crypto import RSA
email = u'email@example.com' #fails
email = str(email) # succeeds
rsa = RSA.load_pub_key('rsa_pubkey.pem')
result = rsa.public_encrypt(email, RSA.pkcs1_padding).encode('base64')