C++ 中的 GUID Linux GCC 应用程序
我有很多服务器运行这个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
此互联网草案详细描述了一种类型的 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.
有libuuid。
There is libuuid.
如果您打算使用某些东西,那么互联网标准将是一个好主意:
查看 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
有一个 Boost 版本可用。
http:// www.boostpro.com/vault/index.php?action=downloadfile&filename=uuid_v11.zip&directory=&PHPSESSID=69e18b945f686398b963710fd52f143a
There is a Boost version available.
http://www.boostpro.com/vault/index.php?action=downloadfile&filename=uuid_v11.zip&directory=&PHPSESSID=69e18b945f686398b963710fd52f143a