Skip to content

Instantly share code, notes, and snippets.

@GitMirar
Created January 24, 2020 23:13
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 GitMirar/4326fecc037e9c1e378ceefca6a7d7f1 to your computer and use it in GitHub Desktop.
Save GitMirar/4326fecc037e9c1e378ceefca6a7d7f1 to your computer and use it in GitHub Desktop.
def _rotr(num, bits):
num &= (2**bits-1)
bit = num & 1
num >>= 1
if(bit):
num |= (1 << (bits-1))
return num
def rotr(num):
key = 13
for i in range(key):
num = _rotr(num, 32)
return num
def hash(s):
h = 0
i = 0
for c in s:
h = rotr(h)
h += ord(c)
i = i + 1
return h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment