如何在.NET中生成版本1 Guid? [英] How to generate a version 1 Guid in .NET?
问题描述
据我了解,在Windows 2000或附近版本中,依赖时间戳和MAC地址的版本1指南已由版本4取代-更加随机.
As I understand it, Version 1 Guids that relied on timestamps and MAC address, were replaced by Version 4 - more random - in Windows 2000 or thereabouts.
如果我更喜欢从版本4开始,从.Net生成版本1 guid的最简单方法是什么?
What's the easiest way to generate a Version 1 guid from .Net, if I prefer it to a version 4?
(我要做希望时间戳和(几乎)唯一的机器ID可提取.我确实控制了整个环境-我可以接受隐私保护/绝对随机性的任何损失)
(I do want the timestamp and (almost) unique machine id to be extractable. I do control the entire environment - I'm ok with privacy/any loss of absolute randomness)
谢谢.
推荐答案
P/调用 UuidCreateSequential
-它返回1类导航:
P/Invoke UuidCreateSequential
- it returns type 1 guids:
出于安全原因,已修改
UuidCreate
,使其不再使用计算机的MAC地址生成UUID.引入UuidCreateSequential
允许使用机器的以太网卡的MAC地址创建UUID.
For security reasons,
UuidCreate
was modified so that it no longer uses a machine's MAC address to generate UUIDs.UuidCreateSequential
was introduced to allow creation of UUIDs using the MAC address of a machine's Ethernet card.
这篇关于如何在.NET中生成版本1 Guid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!