Skip to content

Instantly share code, notes, and snippets.

@drslump
Created February 18, 2014 07:34
Show Gist options
  • Save drslump/9066219 to your computer and use it in GitHub Desktop.
Save drslump/9066219 to your computer and use it in GitHub Desktop.
djb2 hash implementation
def djb2(data as string):
""" Computes a 32bit hash using the djb2 algorithm """
payload = System.Text.Encoding.ASCII.GetBytes(data)
result as uint = 5381
for ch in payload:
unchecked:
result = result * 33 + ch
return result & 0xffffffff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment