Find out what may be preventing you generating high quality random numbers, and more!

Not really, as we can see.

So perhaps we can provide a random number as seed to the random generator?

Tux mascot jumping from Windows to Linux.

This problem is called a problem of ‘random entropy’ generation.

The more entropy we can generate, the better our random numbers will be.

Random is thus never really random.

Article image

Shutterstock/David Orcea

So, how can we generate a random number ‘good enough’ to be named truly random?

We could think about using the date of today, but that isn’t very random on second thoughts.

Maybe, but all one needs is a log file somewhere and the epoch can be reconstructed.

Generating a random number in Bash

Let’s look at this a little closer.

This means our minimum seed is 0 and our maximum seed is 999999.

This is only a range of 1 million numbers.

Is a random number in Bash truly random?

It surely would be a very poor solution for an encryption key generation, for example!

If we select less numbers, the risk for this gets larger.

If we select more, the risk becomes smaller, but the ‘random seed’ becomes less random too.

Assigning a random number as seed to the random generator in Bash

This can be exemplified by including the seconds since epoch:

We can see the seconds ticking over!

Note the initial 6 > 7 > 8 etc.

True random number generation is a not a straightforward matter.

A better random number seed generator

Especially devices which are not only hardware based may be the key to generate that perfect random number.

The issue with random entropy generation using seconds