All pastes #84495 Raw Edit

cladhaire

public text v1 · immutable
·published 2006-07-10 23:53 UTC
rendered paste body
local SOME_PRIME = 16777213

function CheckSum(text)
	local counter = 1
	local sum = 1
	for i=1,string.len(text) do
		local c = string.byte(text, i)
		counter = counter + (c + i) * 17
		sum = sum + c * i 
    end
	counter = counter * sum
	counter = math.mod(counter, SOME_PRIME)
	return string.format("%06x", counter)
end