C++ 中的 GUID Linux GCC 应用程序

发布于 2024-07-07 00:13:37 字数 300 浏览 19 评论 0原文

我有很多服务器运行这个 Linux 应用程序。 我希望他们能够生成一个碰撞概率较低的 GUID。 我确信我可以从 /dev/urandom 中提取 128 个字节,这可能没问题,但是有一个简单的 & 方法吗? 生成一个更相当于 Win32 GUID 的简单方法? 具体来说,是考虑空间(好吧,MAC 地址)、时间和随机性的一个? 我不想取消它的盒子,我只是想要类似 CreateGuid 的东西()

I've got a bunch of servers running this Linux app. I'd like for them to be able to generate a GUID with a low probability of collision. I'm sure I could just pull 128 bytes out of /dev/urandom and that would probably be fine, but is there a simple & easy way to generate a GUID that is more equivalent to the Win32 one? Specifically, one that takes into account space (well, MAC address), time, and randomness? I don't want to call off the box for it, I just want something like CreateGuid()

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

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

发布评论

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

评论(4

百变从容 2024-07-14 00:13:38

互联网草案详细描述了一种类型的 UUID当我需要 UUID 实现并且由于架构原因无法链接到现有库时,我使用了类似的方法并取得了巨大成功。

这篇文章提供了很好的概述。

This Internet Draft describes one type of UUID in great details and I have used a similar approach with great success when I needed a UUID implementation and could not link to an existing library for architectural reasons.

This article provides a good overview.

尘世孤行 2024-07-14 00:13:38

libuuid

There is libuuid.

怪异←思 2024-07-14 00:13:38

如果您打算使用某些东西,那么互联网标准将是一个好主意:
查看 RFC(请求评论)。

我知道特定于 GUID 的 RFC 是:
RFC 4122

If you are going to use something then an Internet standard would be a good idea:
Check out RFC (Request For Comment).

The one I know that is specific to GUID is:
RFC 4122

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