I'm trying to get a better understanding of cryptographic hashing. Take the example transformation function below, is it possible to reverse this formula to solve/isolate for message[i]?
digest [i] = ((129 * message[i]) XOR message[i-1]) % 256
Here is my attempt in python. I Assume both digest and message are 16 bytes in length. It should return the message used to create the digest but is not working. I don't think my operations (a,b,c) are sound.
def answer(digest):
message = [0]
for i,x in enumerate(digest):
a = digest[i] * 129
b = a ^ message[i]
c = b % 256
message.append(c)
print "%d * 129 \t->\t %d ^ %d \t->\t %d MOD 256 \t->\t %d " % (digest[i], a, message[i], b, c)
return message[1:]
digest[0]
? $\endgroup$