Pau*_*cks 5 algorithm hash hashcode simhash
是否有一个哈希函数,输入的微小变化会导致输出的微小变化?例如,类似:
hash("Foo") => 9e107d9d372bb6826bd81d3542a419d6
hash("Foo!") => 9e107d9d372bb6826bd81d3542a419d7 <- note small difference
Run Code Online (Sandbox Code Playgroud)
一个简单的解决方案是将所有字节模块 NEg 异或为 64 位哈希,您需要异或 (input[0] ^ input[8] ^ input[16]) + 256*(input[1] ^ input[9 ] ^ input[17]) 等。因此,“Foo”哈希为“Foo\0\0\0\0\0”和“Foo!” 哈希为“Foo!\0\0\0\0”。