Syntax Invalid While Translating C Code To Python
I have C snippet(decompiled from IDA) to be translated to Python: # v29 = 0; # v30 = -1342924972; # while ( v29 < v62 ) // v62 is length of string to be decoded # { #
Solution 1:
As mentioned, hex
returns a string, which obviously does not support bitwise operations like &
with a numeric type:
>>> type(hex(3))
<class'str'>
>>> hex(3) & 0xf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for &: 'str'and'int'
The ord
function already returns an int, so you can just remove the hex
function altogether:
>>>ord('c') & 0xff
99
Post a Comment for "Syntax Invalid While Translating C Code To Python"