mirror of https://github.com/AxioDL/metaforce.git
Change how 32bit hashes are calculated to prevent collisions
This commit is contained in:
parent
86f9f62ef6
commit
d67d54ddd0
|
@ -51,7 +51,8 @@ class PathHasher:
|
|||
writepipestr(path.encode())
|
||||
read_str = readpipestr()
|
||||
if len(read_str) >= 16:
|
||||
return int(read_str[0:16], 16) & 0xffffffff
|
||||
hash = int(read_str[0:16], 16)
|
||||
return (hash & 0xffffffff) ^ ((hash >> 32) & 0xffffffff)
|
||||
return 0
|
||||
|
||||
def hashpath64(self, path):
|
||||
|
|
|
@ -536,7 +536,7 @@ public:
|
|||
Hash(uint64_t hashin)
|
||||
: hash(hashin) {}
|
||||
Hash(const Hash& other) {hash = other.hash;}
|
||||
uint32_t val32() const {return uint32_t(hash);}
|
||||
uint32_t val32() const {return uint32_t(hash) ^ uint32_t(hash >> 32);}
|
||||
uint64_t val64() const {return uint64_t(hash);}
|
||||
size_t valSizeT() const {return size_t(hash);}
|
||||
Hash& operator=(const Hash& other) {hash = other.hash; return *this;}
|
||||
|
|
Loading…
Reference in New Issue