Created
December 1, 2016 02:26
-
-
Save rhenning/1981d2d4093ef3a84b9631a41b395856 to your computer and use it in GitHub Desktop.
djb2 string to integer hash algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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