I am trying to solve an bytes operation:
0x25 ^ (0xFFFFFFFF << 1) = 0x87654321 * x
I am trying to find the value of x that would make this statement true.
The expressions 0x25 ^ (0xFFFFFFFF << 1)
and 0x87654321
evaluate to nothing but integers, respectively 8589934555
and 2271560481
.
And if you want to solve 8589934555 == 2271560481 * x
, well you just divide.
# Reminder: in Python3, / will always output a float
x = (0x25 ^ (0xFFFFFFFF << 1)) / 0x87654321 # Output: 3.781512588746256
0x25 ^ (0xFFFFFFFF << 1) == 0x87654321 * x # Evaluates to True
You might have been overthinking this, keep in mind that 0x25
is nothing but hexadecimal notation for an integer. It means that, for Python it is exactly the same as writing 37
.
Moreover operations such as ^
and <<
will return integers as well, so there really is nothing to worry about once you get the value they output. Elementary algebra still applies.