Skip to content

Instantly share code, notes, and snippets.

@scheler
Created July 23, 2020 00:17
Show Gist options
  • Save scheler/26a942d34fb5576a68c111b05ac3fabe to your computer and use it in GitHub Desktop.
Save scheler/26a942d34fb5576a68c111b05ac3fabe to your computer and use it in GitHub Desktop.
String hash function in Lua
function hash(str)
h = 5381;
for c in str:gmatch"." do
h = ((h << 5) + h) + string.byte(c)
end
return h
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment