Skip to content

Instantly share code, notes, and snippets.

@rhenning
Created December 1, 2016 02:26
Show Gist options
  • Save rhenning/1981d2d4093ef3a84b9631a41b395856 to your computer and use it in GitHub Desktop.
Save rhenning/1981d2d4093ef3a84b9631a41b395856 to your computer and use it in GitHub Desktop.
djb2 string to integer hash algorithm
i = 5381
k = 33
out = ARGF.read.each_char.inject(i) do |h, c|
h * k + c.ord
end
puts out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment