实现Java字符串的Hash算法

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

hash = function(input)
	input = tostring(input);
	local h = 0
	local len = string.len(input)
	local max = 2147483647
	local min = -2147483648
	local cycle = 4294967296

	for i=1, len do
		h = 31 * h + string.byte(string.sub(input, i, i));
		while h > max do
			h = h - cycle
		end
		while h < min do
			h = h + cycle
		end
	end
	return h
end