是否有任何不明显的滥用 GUID 的方式?

发布于 2024-08-15 02:39:52 字数 184 浏览 2 评论 0原文

GUID 通常用于唯一地标识各种实体 - 来自外部系统、文件等的请求。像魔术一样工作 - 您调用“GiveMeGuid()”(Windows 上的 UuidCreate())函数 - 一个全新的 GUID 随时为您服务。

鉴于我的代码每次需要新的 GUID 时都会调用“GiveMeGuid()”函数,是否有任何不那么明显的方式来滥用它?

GUIDs are typically used for uniquely identifying all kinds of entities - requests from external systems, files, whatever. Work like magic - you call a "GiveMeGuid()" (UuidCreate() on Windows) function - and a fresh new GUID is here at your service.

Given my code really calls that "GiveMeGuid()" function each time I need a new GUID is there any not so obvious way to misuse it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

独木成林 2024-08-22 02:39:52

刚刚找到了一个老问题的答案:.Net GUID 的确定性如何?。重新引用它:

这不是一个完整的答案,但我可以告诉你,第 13 个十六进制数字始终是 4,因为它表示用于生成 GUID 的算法版本(id est,v4);另外,我引用维基百科:

<块引用>

WinAPI GUID 生成器的密码分析表明,由于 V4 GUID 的序列是伪随机的,因此在给定初始状态的情况下,我们可以预测函数 UuidCreate 返回的最多 250 000 个 GUID。这就是为什么 GUID 不应该在密码学中使用,例如作为随机密钥。

所以,如果你足够幸运并获得相同的种子,你将依次打破 250k 镜子。引用另一篇维基百科文章

虽然不能保证每个生成的 GUID 都是唯一的,但唯一键的总数(2128 或 3.4×1038)非常大,因此相同的数字生成两次是极小的。

底线:认为 GUID始终是唯一的,这可能是一种误用形式。

Just found an answer to an old question: How deterministic Are .Net GUIDs?. Requoting it:

It's not a complete answer, but I can tell you that the 13th hex digit is always 4 because it denotes the version of the algorithm used to generate the GUID (id est, v4); also, and I quote Wikipedia:

Cryptanalysis of the WinAPI GUID generator shows that, since the sequence of V4 GUIDs is pseudo-random, given the initial state one can predict up to the next 250 000 GUIDs returned by the function UuidCreate. This is why GUIDs should not be used in cryptography, e.g., as random keys.

So, if you got lucky and get same seed, you'll break 250k mirrors in sequence. To quote another Wikipedia piece:

While each generated GUID is not guaranteed to be unique, the total number of unique keys (2128 or 3.4×1038) is so large that the probability of the same number being generated twice is extremely small.

Bottom line: maybe a misuse form it's to consider GUID always unique.

凉墨 2024-08-22 02:39:52

这取决于。 GUID 生成的某些实现与时间相关,因此快速连续调用 CreateGuid 可能会产生冲突的 GUID。

编辑:我现在记得这个问题了。我曾经在编写一些 php 代码,其中 GUID 生成函数在每次调用时使用系统时间重新播种 RNG。不要这样做。

It depends. Some implementations of GUID generation are time dependant, so calling CreateGuid in quick succession MAY create clashing GUIDs.

edit: I now remember the problem. I was once working on some php code where the GUID generating function was reseeding the RNG with the system time each call. Don't do this.

为你拒绝所有暧昧 2024-08-22 02:39:52

我认为滥用 Guid 的唯一方法是尝试以某种逻辑方式解释该值。并不是说它真的邀请您这样做,这是我真正喜欢的 Guid 的特性之一。

The only way I can see of misusing a Guid is trying to interpret the value in some logical manner. Not that it really invites you to do so, which is one of the characteristics around Guid's that I really like.

∞琼窗梦回ˉ 2024-08-22 02:39:52

有些 GUID 包含生成它的计算机的一些标识符,因此可以在客户端/服务器环境中使用,但有些则不能。请确保您的数据库不使用它们,例如多个客户端访问的数据库。

Some GUIDs include some identifier of the machine it was generated on, so it can be used in client/server environments, but some can't. Be sure if yours doesn't to not use them in, for instance, a database multiple clients access.

离线来电— 2024-08-22 02:39:52

也许可以通过首先使用一些用于生成 GUID 的参数(例如接口标识符)来操纵熵。

Maybe the entropy could be manipulated by playing with some parameters used to generate the GUIDs in the first place (e.g. interface identifiers).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文