cipher.encrypt(plaintext) bring to TypeError
wwwshellcodeit opened this issue · 1 comments
wwwshellcodeit commented
Hi,
Issue: cipher.encrypt need bytes and not string.
The return line on encrypt function bring to:
Traceback (most recent call last):
File "RAU_crypto.py", line 327, in <module>
mode_Post()
File "RAU_crypto.py", line 285, in mode_Post
print(upload(TempTargetFolder, Version, payload_filename, url))
File "RAU_crypto.py", line 201, in upload
payload_filename
File "RAU_crypto.py", line 163, in payload
data += rauPostData_prep(quiet, TempTargetFolder, Version) + "\r\n"
File "RAU_crypto.py", line 111, in rauPostData_prep
RAUCipher.encrypt(TempTargetFolder),
File "RAU_crypto.py", line 76, in encrypt
return base64.b64encode(cipher.encrypt(plaintext)).decode()
File "C:\Python36\lib\site-packages\Crypto\Cipher\_mode_cbc.py", line 162, in
encrypt
c_uint8_ptr(plaintext),
File "C:\Python36\lib\site-packages\Crypto\Util\_raw_api.py", line 196, in c_u
int8_ptr
raise TypeError("Object type %s cannot be passed to C code" % type(data))
TypeError: Object type <class 'str'> cannot be passed to C code
Anyway I solved such issue changing from:
return base64.b64encode(cipher.encrypt(plaintext)).decode()
To:
return base64.b64encode(cipher.encrypt(plaintext.encode('utf-8'))).decode()
Thanks
bao7uo commented
Your issue was fixed with this commit:
4667c39#diff-6c18475af6200dc4600663b24fa14d36