user1019083
user1019083

Reputation: 381

non deterministic way to generate random large numbers

What is the best non-deterministic way to generate large random numbers? I wrote a code to generate large numbers using a time function, but it is deterministic.

Upvotes: 0

Views: 872

Answers (3)

Raymond Hettinger
Raymond Hettinger

Reputation: 226296

On Linux machines /dev/urandom is a source of non-deterministic random numbers.

Another technique is to download some non-random material from the internet (news articles, stock quotes, etc); compress them (using zip or somesuch); then encrypt them with good encryption software (such as AES). The resulting stream of bytes is random (for most practical purposes).

Upvotes: 1

Jonathan
Jonathan

Reputation: 1223

It's much safer to use a random number generator provided by your OS or your programming language. It's really hard to write a random number generator that doesn't produce any discernable patterns.

And as drdwilcox said above, you can't have a truly non-deterministic random number generator unless you have truly random input, which requires some kind of hardware.

Upvotes: 1

Related Questions