Le mer. 27 mai 2020 à 04:39, 云风 Cloud Wu <
cloudwu@gmail.com> a écrit :
>
> I wrote a script to check the collision of those hash functions by
> simulating lua hash tables [1].
> [1] :
https://gist.github.com/cloudwu/61befc67d5ef6eee7ef8fda251612439Note that there's a small bug in your simulation:
local function hashstring(str, func)
local h = seed
str:gsub(".", function (c) h = h ~ ( func(h, c:byte()) & 0xffffffff ) end)
return h
end
The initialisation should be:
local h = seed ~ #str -- the string length (or at least some low-order bits) should also be hashed (xor'ed with the seed)