Hash function in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hamedpersian
    New Member
    • Feb 2012
    • 3

    Hash function in python

    I have written some hash code and it supposed to have a 32 bits output. But i don't know how to make it 32 bit as the output. please help me with this. Here is my code:
    Code:
    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()
Working...