import hashlib as H f=[ 0xDA, 0xE5, 0x23, 0x10, 0x06, 0x71, 0x95, 0x71, 0x4B, 0xA2, 0xCE, 0xE2, 0x33, 0x2B, 0xB8, 0x66] user=[ 0x35, 0x44, 0x37, 0x38, 0x43, 0x33, 0x46, 0x44, 0x46, 0x32, 0x31, 0x39, 0x39, 0x38, 0x41, 0x43] serial=list('F3A0FD8D8DE1FEB889808A8FF2D7FDA2'.decode('hex')) serial=map(ord,serial) print serial r=[0 for i in range(16)] for i in range(len(user)): r[i]=user[i]^serial[i] ''' r=''.join(map(chr,r)) md5=H.md5(r).hexdigest() print md5 ''' right_user=[ 0x4B, 0x43, 0x54, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] right_serial=[0 for i in range(16)] for i in range(len(user)): right_serial[i]=right_user[i]^r[i] print ((''.join(map(chr,right_serial))).encode('hex')).upper()