I recently came across this interesting equation (from the spectre code) that Mixes the value of a byte:
MixedByte = ((ByteToMix * 167) + 13) & 0xFF
or
MixedByte = BITAND((ByteToMix * 167) + 13, 255)
Which returns for each value 0-255 a mixed value 0-255 without duplicates or missing values. Ie. Reorders the values.
Since my maths is not that great I played around with the equation trying to figure out the inverse function.
Through trail and error I eventually stumbled across the solution:
OriginalByte = (MixedByte * 23 + 213) & 0xFF
or
OriginalByte = BITAND(MixedByte * 23 + 213, 255)
Can anyone explain how I could have determined the correct inverse function without using trail and error?