Is there a greater chance to collide when comparing GUIDs created differently?

不羁岁月 提交于 2019-12-12 14:13:27

问题


If I create a GUID using the constructor (say, Guid myGuid = new Guid("myguid")), is there a higher chance that it would collide with a GUIDs created with Guid.NewGuid() vs. two GUIDs both created with Guid.NewGuid()?

EDIT:

More specific question: Is there a greater chance to collide when comparing GUIDs based on a hash vs "Guid.NewGuid()?


回答1:


The real answer is it depends. Guid.NewGuid creates it based on several factors described here. If you take the string representation of creating it from NewGuid and you put that in the constructor, then the chance is the same as calling NewGuid twice.

That being said, not all GUIDs are created equal. Different systems have different ways of generating them, and they may not be as collision resistant as the .NET implementation. There is nothing to say that I couldn't create a string which could be parsed into GUIDs which isn't based on any rules. This GUID would have a much greater chance of a collision.




回答2:


If "myguid" value was created by legal GUID generator, then it's a equal chance.




回答3:


With the newest GUID generator on Windows, which is pretty much a secure random number generator, the probability of guessing the next number and passing it to new Guid("myguid") is next to impossible.

It was different with older generators, when a GUID could be traced back to the hardware on which it has been created. Back then you could reverse-engineer the process of generating GUIDs, and try passing a colliding GUID on purpose.



来源:https://stackoverflow.com/questions/35661915/is-there-a-greater-chance-to-collide-when-comparing-guids-created-differently

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!