问题
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