BoodyBruh
BoodyBruh

Reputation: 3

Reversing a bitwise operation

If I have for example: a = (b << 8) | (c << 4) | d how would I get b c and d from a? Or if I had a and d and needed to get b and c?

Upvotes: 0

Views: 116

Answers (1)

Henry Twist
Henry Twist

Reputation: 5980

Unfortunately there isn't a single solution for a problem like this (unless in very specific cases). The OR operator (|) doesn't have an inverse, so even the simplified problem of:

a = b | c

where a and c are known, is not solvable (at least to get a single solution).


For a more practical example, you can consider something super simple:

11 = 10 | c

then c could either be 11 or 01 and the number of solutions keep growing with the number of bits.

Upvotes: 2

Related Questions