sql-server – 如何在SQL Server中生成GUID?

前端之家收集整理的这篇文章主要介绍了sql-server – 如何在SQL Server中生成GUID?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在sql Server中生成GUID?

我知道我应该使用newid(),但函数使用的算法是什么?它是时间/日期的哈希吗?

解决方法

创建它的算法在这里描述: http://en.wikipedia.org/wiki/Globally_Unique_Identifier

Algorithm

In the OSF-specified algorithm for generating new (V1) GUIDs,the user’s network card MAC address is used as a base for the last group of GUID digits,which means,for example,that a document can be tracked back to the computer that created it. This privacy hole was used when locating the creator of the Melissa worm[2]. Most of the other digits are based on the time while generating the GUID. V1 GUIDs which contain a MAC address and time can be identified by the digit “1” in the first position of the third group of digits,for example {2f1e4fc0-81fd-11da-9156-00036a0f876a}. V4 GUIDs use the later algorithm,which is a pseudo-random number. These have a “4” in the same position,for example {38a52be4-9352-453e-af97-5c3b448652f0}. More specifically,the ‘data3’ bit pattern would be 0001xxxxxxxxxxxx in the first case,and 0100xxxxxxxxxxxx in the second. Cryptanalysis of the WinAPI GUID generator shows that,since the sequence of V4 GUIDs is pseudo-random; given full knowledge of the internal state,it is possible to predict prevIoUs and subsequent values

原文链接:https://www.f2er.com/mssql/83833.html

猜你在找的MsSQL相关文章