昨天研究这个主题,我发现了几个有趣的问题(例如this one https://stackoverflow.com/questions/35366368/does-uuidcreate-use-a-csprng)关于 GUID 最终是如何生成的。简单来说;看起来Guid.NewGuid();
calls CoCreateGuid
在 COM 中,依次调用UuidCreate
在 Windows RPC 中(文档here https://msdn.microsoft.com/en-us/library/ms688568(VS.85).aspx and here https://msdn.microsoft.com/en-us/library/aa379205(v=vs.85).aspx).
我发现自己在想;当操作系统处于notWindows,例如 .NET Core 可能会出现这种情况,这是否会影响“版本”算法 https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions用于生成 GUID(据我所知是 Windows 上的版本 4)?
在非 Windows 计算机上,.NET Core 将使用uuid_create https://www.freebsd.org/cgi/man.cgi?query=uuid_create在 BSD(即“版本 1”)或 libuuid 上uuid_generate_random https://linux.die.net/man/3/uuid_generate_random在 macOS 和 Linux(“版本 4”)上运行。
替换的实施CoCreateGuid
函数可以在GitHub 上的 CoreCLR 源代码 https://github.com/dotnet/coreclr/blob/32f0f9721afb584b4a14d69135bea7ddc129f755/src/pal/src/misc/miscpalapi.cpp#L355.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)