I’m in the middle of writing a simple hash function which get the input and creates a 32 bit hash file. I’m stuck in the xor part. And i’m not sure how i should write the function for xor. please help me with this. here is the code that i have done yet:
import BitVector
import io
import math
import struct
if __name__ == "__main__":
message = raw_input("your message:")
f= open('file.dat','w')
f.write(message)
f.close()
f = open('file.dat')
while 1:
r = f.readline(1)
hx = r.encode("hex")
data = bin(int(hx, 16))[2:]
key = 11111111
x = int(data) ^ int(key)
print hex(x)
if not r:break
f.close()
try using this for xoring:
For binary xoring, where data and key are binary values and using
^character,you can use:
Let me know if this helps.