APR::UUID 模块生成的标识符的唯一性保证是什么

发布于 2024-12-20 20:25:41 字数 303 浏览 2 评论 0原文

Data::UUID 的文档指出

UUID 的长度为 128 位,并且保证与所有 UUID 不同 直到公元 3400 年才生成其他 UUID/GUID。

APR::UUID 的文档将生成的标识符描述为 随机。

这是否意味着 APR::UUID 创建的 GUID 不能保证是唯一的?

The documentation of Data::UUID states that

A UUID is 128 bits long, and is guaranteed to be different from all
other UUIDs/GUIDs generated until 3400 CE.

The documentation for APR::UUID describes the generated identifiers as random.

Does this mean that the GUIDs created by APR::UUID are not guaranteed to be unique?

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

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

发布评论

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

评论(2

对风讲故事 2024-12-27 20:25:41

关于 UUIDsGUIDs 在这里具有指导意义。

UUID 是随机的,但来自如此大的分布,以至于碰撞的概率很小,在这种情况下,很小意味着在生成两个相同的 UUID 之前,您可能会被数千颗小行星撞击。

GUID 大多是随机的,但也将一些确定性但独特的数据合并到您的系统中,例如网络硬件的 MAC 地址和当前时间,因此在另一个系统上创建的 GUID 之间发生冲突的可能性更小。

The Wikipedia articles on UUIDs and GUIDs are instructive here.

UUIDs are random but drawn from such a large distribution that the probabilities of collisions are miniscule, where in this context miniscule means that you are likely to be struck by thousands of asteroids before you generate two identical UUIDs.

GUIDs are mostly random but also incorporate some deterministic but unique data to your system, such as the MAC address of your network hardware and the current time, so that collisions between a GUID created on another system are even less likely.

独享拥抱 2024-12-27 20:25:41

我意识到这是一个老问题,但当我偶然发现这个问题时,我想我应该分享一些观察结果。

正如 daxim 所说,APR::UUID 使用 libuuid。然而,至少在某些实现中,libuuid 不会生成随机 (v4) UUID,而是生成 v1 UUID(基于 MAC 地址和时间戳)。这些确实是唯一的(只要您的 MAC 地址确实是唯一的),但它们会泄露信息(您的 MAC 地址和 UUID 生成的时间),并且至少在某种程度上是可预测的。

如果 UUID 生成代码符合规范,您可以通过查看 3 组的第一位数字来找出生成的 UUID 版本。 v1 UUID 不是随机的而是可预测的。 v4 UUID 是随机的并且(据说)不可预测。

I realise this is an old question, but as I stumbled unto this issue, I thought I would share some observations.

As stated by daxim, APR::UUID uses libuuid. However, in at least some implementations, libuuid does not generate a random (v4) UUID, but a v1 UUID (based on MAC address and timestamp). These are really unique (as long as your MAC address is indeed unique), but they leek information (your MAC address and the time the UUID was generated) and may be at least somewhat predictable.

If the UUID generation code is spec-compliant, you can find out which version of UUID is generated by looking at the first digit of the 3 group. v1 UUIDs are not random but predictable. v4 UUIDs are random and (supposedly) unpredictable.

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