I think a short description or demonstration of what can go wrong, and by how much, when the hashing scheme is suboptimal would have been helpful.
@joeedh10 күн бұрын
I've done hashing this way for years, use it mostly for detecting when stuff changes.
@R.B.10 күн бұрын
I can understand how for some hashes the order of the object keys might be important, but it also seems as though that might be unnecessary. If the hasher is generating a uniform distribution with a low probability of collision, because of how it is tuned, then flipping a single bit for one hash should not have any shared structure with another hash; in other words hash(1) and hash(2) should have the same entropy. And if that is the case, then xoring these hashes together should still retain the same entropy, but now you aren't dependent on the order of which structure you hashed first. The risk of such a mechanism is if you have a complex struct where two objects members may be interchangable, but they should be treated as different entities. As a completely made up example you might have one order where the customer is "A" and the seller is "B", but in another transaction where the customer is now the seller and vice versa, there isn't any distinction, xoring these values together would result in the same hash, but again if these are uniformly distributed, the hash combiner could perform a preselected rol or ror operation for the state before xoring a subsequent member. This sort of strategy would allow you to be selective with regard to what members the order is critical and for those where it is not. It does require that the hash algorithm itself is a wide key range, uniform, and unlikely to generate collisions, but if those properties are true then rotating the bits and xoring should retain that property, just as generating a random number, rotating it, and xoring it with another random number, it wouldn't be possible to recover either random number from the result.
@tylovset10 күн бұрын
Yes, two high entropy hashes can be combined with xor, and the result is a high entropy hash. The only case to consider is when the two hashes are equal, it will result in 0. To avoid that issue, combined_hash += combined_hash ^ input_hash, is all you need.
@briansalehi11 күн бұрын
Honestly, I couldn't follow through the topic. I wish we had some short conclusion part at the end.