.net - Fastest way to hash a set of GUIDs -
i have list of n guids , need hash them single value. value size of guid object or size of int32, doesn't matter, need statistically unique (say similar md5).
so 1 approach sort them, concatenate bytes , take md5 hash of bytes... isn't quick.
another idea: notice standard practice in .net implement gethashcode method of composing object xor of hash codes of composed objects. therefore mathematically sensible xor list of guids?
any ideas welcome!
if want hash valid set (i.e. order doesn't matter) xoring hashcode of each guid choice.
if you've got sequence of guids , order matters i'd suggest using same approach wrote in answer - repeatedly add/multiply.
(note xoring hashcodes won't same answer xoring guids , hashing result. may be, depends on implementation of guid.gethashcode(). i'd hash each value , xor results - aside else, that's trivial implement.)
Comments
Post a Comment