True random generation in Java

后端 未结 13 2329
一生所求
一生所求 2020-12-01 01:18

I was reading the Math.random() javadoc and saw that random is only psuedorandom.

Is there a library (specifically java) that generates random numbers according to

13条回答
  •  半阙折子戏
    2020-12-01 02:08

    Since tapping into those sources of random data would require hardware access of some kind such a library can't be written portably using pure Java.

    You can however try to write platform-dependent code to read the platforms source of random data. For Linux (and possibly other Unix-like systems as well) that could be /dev/random for example.

    Also, look at the SecureRandom class, it might already have what you want.

提交回复
热议问题