True random generation in Java

后端 未结 13 2317
一生所求
一生所求 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:09

    As far as i know they work with time of the machine ... !

    What Random Numbers Are Used For

    Random numbers have been used for many thousands of years. Whether it’s flipping a coin or rolling a dice, the goal is to leave the end result up to random chance. Random number generators in a computer are similar — they’re an attempt to achieve an unpredictable, random result.

    Is this possible to make true random numbers ?

    Yes it is !

    To generate a “true” random number, the computer measures some type of physical phenomenon that takes place outside of the computer.

    For a more day-to-day example, the computer could rely on atmospheric noise or simply use the exact time you press keys on your keyboard as a source of unpredictable data, or entropy. For example, your computer might notice that you pressed a key at exactly 0.23423523 seconds after 2 p.m.. Grab enough of the specific times associated with these key presses and you’ll have a source of entropy you can use to generate a “true” random number.

    The NSA and Intel’s Hardware Random Number Generator

    To make things easier for developers and help generate secure random numbers, Intel chips include a hardware-based random number generator known as RdRand. This chip uses an entropy source on the processor and provides random numbers to software when the software requests them.

    source : HowToGeek ?

    Just in case that you maybe need to generate random numbers in Android... I use Data of Accelerometer for true physic based random numbers :)

提交回复
热议问题