Skip to content

Instantly share code, notes, and snippets.

@bofh19
Created February 1, 2014 08:40
Show Gist options
  • Save bofh19/8749684 to your computer and use it in GitHub Desktop.
Save bofh19/8749684 to your computer and use it in GitHub Desktop.
Java String.hashCode() in python
def java_string_hashcode(s):
h = 0
for c in s:
h = (31 * h + ord(c)) & 0xFFFFFFFF
return ((h + 0x80000000) & 0xFFFFFFFF) - 0x80000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment