Is a GUID unique 100% of the time?
Is a GUID unique 100% of the time?
回答1
While each generated GUID is not guaranteed to be unique, the total number of unique keys (2128 or 3.4×1038) is so large that the probability of the same number being generated twice is very small. For example, consider the observable universe, which contains about 5×1022 stars; every star could then have 6.8×1015 universally unique GUIDs.
From Wikipedia.
These are some good articles on how a GUID is made (for .NET) and how you could get the same guid in the right situation.
https://ericlippert.com/2012/04/24/guid-guide-part-one/
https://ericlippert.com/2012/04/30/guid-guide-part-two/
https://ericlippert.com/2012/05/07/guid-guide-part-three/
Summing up:
- GUIDs are guaranteed to be unique but not guaranteed to be random. Do not use them as random numbers.
- GUIDs that are random numbers are not cryptographic strength random numbers.
- GUIDs are only unique when everyone cooperates; if someone wants to re-use a previously-generated GUID and thereby artificially create a collision, you cannot stop them. GUIDs are not a security mechanism.
- GUIDs have an internal structure; at least six of the bits are reserved and have special meanings.
- GUIDs are allowed to be generated sequentially, and in practice often are.
- GUIDs are only unique when taken as a whole.
- GUIDs can be generated using a variety of algorithms.
- GUIDs that are generated randomly are statistically highly unlikely to collide in the foreseeable future.
- GUIDs could reveal information about the time and place they were created, either directly in the case of version one GUIDs, or via cryptanalysis in the case of version four GUIDs.
- GUIDs might be generated by some entirely different algorithm in the future.
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2021-01-21 What is the difference between --save and --save-dev?
2021-01-21 Webpack - A Detailed Introduction
2021-01-21 Webpack Tutorial: Understanding How it Works
2021-01-21 How to use Babel without Webpack
2021-01-21 babel-loader
2021-01-21 Babel is a JavaScript compiler.
2021-01-21 Compiling vs Transpiling