How to generate a version 1 Guid in .NET?

女生的网名这么多〃 提交于 2020-01-03 11:57:22

问题


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.

What's the easiest way to generate a Version 1 guid from .Net, if I prefer it to a version 4?

(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)

Thanks.


回答1:


P/Invoke UuidCreateSequential - it returns type 1 guids:

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.



来源:https://stackoverflow.com/questions/9411673/how-to-generate-a-version-1-guid-in-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!