java的UUID.randomUUID有多好? [英] how good is java's UUID.randomUUID?

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

问题描述

我知道随机UUID在理论上具有非常非常非常低的碰撞概率,但我想知道,在实践中,Java 5的 randomUUID()没有碰撞?有没有人有经验可以分享?

I know that randomized UUIDs have a very, very, very low probability for collision in theory, but I am wondering, in practice, how good is Java 5's randomUUID() in terms of not having collision? Does anybody have any experience to share?

推荐答案

UUID使用 java.security.SecureRandom ,应该是加密强。虽然没有指定实际的实现,并且JVM之间可能有所不同(意味着任何具体的语句仅对一个特定的JVM有效),但它确实要求输出必须通过统计随机数生成器测试。

UUID uses java.security.SecureRandom, which is supposed to be "cryptographically strong". While the actual implementation is not specified and can vary between JVMs (meaning that any concrete statements made are valid only for one specific JVM), it does mandate that the output must pass a statistical random number generator test.

实现总是可能包含破坏所有这些的细微错误(请参阅OpenSSH密钥生成错误),但我认为没有任何具体理由担心Java UUID的随机性。

It's always possible for an implementation to contain subtle bugs that ruin all this (see OpenSSH key generation bug) but I don't think there's any concrete reason to worry about Java UUIDs's randomness.

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

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