UUID有多独特? [英] How unique is UUID?

查看:102
本文介绍了UUID有多独特?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用UUID唯一标识某事物有多安全(我正在将它用于上传到服务器的文件)?据我了解,它是基于随机数的.但是,在我看来,只要有足够的时间,它最终就会自我重做,只是偶然的机会.是否有更好的系统或某种类型的模式可以缓解此问题?

How safe is it to use UUID to uniquely identify something (I'm using it for files uploaded to the server)? As I understand it, it is based off random numbers. However, it seems to me that given enough time, it would eventually repeat it self, just by pure chance. Is there a better system or a pattern of some type to alleviate this issue?

推荐答案

非常安全:

某人被陨石击中的年风险为 估计有170亿机会,这意味着 概率约为0.00000000006(6×10 −11 ),等于赔率 一年创建数十万亿个UUID并拥有一个 复制.换句话说,只有在每次产生10亿个UUID之后 在接下来的100年中仅次于第二个 重复大约是50%.

the annual risk of a given person being hit by a meteorite is estimated to be one chance in 17 billion, which means the probability is about 0.00000000006 (6 × 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate. In other words, only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%.

注意事项:

但是,这些概率仅在生成UUID时成立 使用足够的熵.否则,重复的可能性 可能会更高,因为统计差异可能会 降低.分布式需要唯一标识符的地方 应用程序,因此即使来自许多应用程序的数据也不会造成UUID冲突 设备被合并,种子和生成器的随机性 在应用程序的生命周期中,每个设备都必须可靠.在哪里 这是不可行的,RFC4122建议使用名称空间变体 代替.

However, these probabilities only hold when the UUIDs are generated using sufficient entropy. Otherwise, the probability of duplicates could be significantly higher, since the statistical dispersion might be lower. Where unique identifiers are required for distributed applications, so that UUIDs do not clash even when data from many devices is merged, the randomness of the seeds and generators used on every device must be reliable for the life of the application. Where this is not feasible, RFC4122 recommends using a namespace variant instead.

来源: 随机UUID发生的可能性Wikipedia文章关于通用唯一标识符的重复部分(链接导致从2016年12月起进行修订,然后对该部分进行了修改).

Source: The Random UUID probability of duplicates section of the Wikipedia article on Universally unique identifiers (link leads to a revision from December 2016 before editing reworked the section).

另请参阅同一通用唯一标识符文章 碰撞 .

Also see the current section on the same subject on the same Universally unique identifier article, Collisions.

这篇关于UUID有多独特?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆