I'm trying to base64 encode some RSA encrypted data, but the RSA encryption returns a tuple and the base64 encoding requires a bytes-like object.
File "C:\PATH\AppData\Local\Continuum\anaconda3\lib\base64.py", line 58, in b64encode encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'tuple'
I'm looking for suggestions to fix this the best way.
from Crypto.Cipher import AES
from Crypto.PublicKey import RSA
def rsa_encrypt(data):
return pub_keyObj.encrypt(data, 32)
def rsa_encrypt_base64(data):
return base64.standard_b64encode(rsa_encrypt(data))
encrypted_data = aes_encode(data, key, iv) #AES encoding is working fine
print("EncryptedString: ", rsa_encrypt_base64(encrypted_data))