Skip to content

Instantly share code, notes, and snippets.

@tanghaibao
Created July 25, 2010 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanghaibao/489761 to your computer and use it in GitHub Desktop.
Save tanghaibao/489761 to your computer and use it in GitHub Desktop.
cython practice for elf hash
cpdef unsigned int elfHash(char *value):
cdef unsigned int i, x, result
result = 0
for i in range(len(value)):
result = (result << 4) + value[i]
x = result & 0xF0000000
if x:
result ^= (x >> 24)
result &= ~x
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment