def rsa_encrypt(data, rsa_pub_key_str):
 key = RSA.importKey(rsa_pub_key_str)
 cipher = PKCS1_OAEP.new(key)
 encrypted_data = cipher.encrypt(data)
 return encrypted_data

def rsa_encrypt ( data , rsa_pub_key_str ) : key = RSA . importKey ( rsa_pub_key_str ) cipher = PKCS1_OAEP . new ( key ) encrypted_data = cipher . encrypt ( data ) return encrypted_data
rsa_pub_key is a string with the public key .