from ctypes import c_uint32, c_int32
unid = "(delete me)"
def hashString(s):
h = 0
for c in s:
h = c_uint32((h * 0x21) + ord(c)).value
return h
def IDLink(s):
parts = s.split(":")
# unid link has affixes in reverse order
affixes = parts[3].split(',')
affixes.reverse()
parts[3] = ','.join(affixes)
# 0x1 on this flag apparently means ID
parts[9] = str(int(parts[9]) | 0x1)
hash_input = ':'.join(parts[1:-2]) + ':'
link_hash = c_int32(hashString(hash_input)).value
parts[-2] = str(link_hash)
id = ':'.join(parts)
return id
print IDLink(unid)