问题
Is there more chance having collisions when betweens GUID's
(128 bits) or SHA1 hashes of GUID's
(160 bits) ? My opinion is there is less chance with a GUID
(even if there is 32 bit less), because it has some special mechanisms to make sure it is (almost, because no guarantee) unique (ex : timestamp)
Note : i already know that a GUID
is very unlikely to have a collision with another GUID
, no more debate about this please.
回答1:
That's trivial: if two GUIDs are the same (that is, for each GUID collision), their hashes are also the same (we have a "collision" which is not a "SHA1 collision", but it's bad enough for our application). Plus there is a probability of a hash collision proper (same SHA1 for different GUIDs).
You can only add collisions if you hash your GUIDs.
来源:https://stackoverflow.com/questions/14861313/is-there-more-chance-having-collisions-between-guids-or-a-sha1-hashes-of-guids