如何在SQL Server中生成GUID? [英] how are GUIDs generated in SQL Server?

查看:242
本文介绍了如何在SQL Server中生成GUID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在SQL Server中生成GUID?

How are GUIDs generated in SQL Server?

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

I understand that I should use newid(), but what is the algorithm that function uses? Is it a hash of the time/date?

推荐答案

此处描述了创建算法的算法:

The algorithm to create it is described here: http://en.wikipedia.org/wiki/Globally_Unique_Identifier

算法

在OSF指定的用于生成新(V1)GUID的算法中, 用户的网卡MAC地址用作最后一组的基础 的GUID位数,例如,这意味着文档可以是 追溯到创建它的计算机.这个隐私漏洞是 在查找梅利莎蠕虫的创建者时使用[2].大部分的 其他数字基于生成GUID的时间. V1 GUID 其中包含MAC地址和时间的可以通过数字标识 例如,第三组数字的第一位置为"1" {2f1e4fc0-81fd-11da-9156-00036a0f876a}. V4 GUID使用更高版本 算法,这是一个伪随机数.这些中有一个"4" 相同的位置,例如{38a52be4-9352-453e-af97-5c3b448652f0}. 更具体地说,"data3"位模式将为0001xxxxxxxxxxxx 在第一种情况下,为0100xxxxxxxxxxxx,在第二种情况下.密码分析 WinAPI GUID生成器的结果表明,由于V4的顺序 GUID是伪随机的;在充分了解内部状态的情况下, 可以预测之前和之后的值

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

这篇关于如何在SQL Server中生成GUID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆