A random number generator (RNG) is a type of a device or a utility that produces symbols or a number sequence at given intervals such that the values can’t be reasonably predicted better than by random chances. Generally, it’s a technology for generating a sequence that doesn’t have any pattern.

A computer produces a number randomly for everything from cryptography to gambling and video games. RNGs are the Achilles heel of cryptography and the brains of the slot machines. Many of the players tend to think that there is a computer chip picking the numbers as they don’t understand how it works leading to some of the many misconceptions about the machine.

There are various types of RNGs; they can either be pseudorandom number generators (PRNG) or true hardware random number generators (TRNG). Ever wondered how computers generate random numbers, and where does the ‘randomness’ come from? The random numbers generated by computers are generally grouped into two categories depending on how they are generated: true random numbers and pseudorandom numbers.

True Random Numbers

They are genuinely generated by the true random number generators. For a true random number to be generated, a computer measures a physical phenomenon of any type that takes place outside the computer such as measuring the radioactive decay of an atom. It is essentially ‘pure randomness’ as there is no way you can surely know when the radioactive decay will occur.

TRNGs don’t require seeds as the true hardware random numbers aren’t computed values and they’re not derived from repetitive operations in the computers. True random numbers can be digitized snapshots of these naturally occurring events such as atmospheric noise.

Hardware RNGs have no algorithms and also no repeating number sequences and even if a hacker determines a single number, he is not able to use it for prediction of any future numbers thus these hardware random number generators are referred to as True Random Number Generators (TRNG).

Pseudorandom Numbers

They are the alternative to true random numbers and they usually look random but are deterministic and they can be regenerated if the state of the pseudo-RNG is known. A computer may use an algorithm and a seed value to generate predictable numbers but they appear to be random.

Some of the repetitive operations for deriving a seed value include running processes, keystrokes, mouse movements, or the computer’s clock. It’s usually difficult to come up with a random seed, however, as most of such operations provide only a small value range.

The different methods used in the generation of random numbers include physical methods, computational methods, generation from a probability distribution, and by humans although it has been found out that there is a certain degree of non-randomness with human subjects when compared to a good RNG when producing a random sequence. RNG technology can be used to generate lottery draws.

Random numbers have been used for many years and the RNGs in a computer are similar, obviously are an attempt to achieve a random unpredictable result. Random number generators are widely used for many different purposes such as cryptography, gambling, and the creation of unpredictable results in a computer game.

Implementation of RNG Technology

Random numbers are usually required for wide ranges of applications such as in data encryption, testing, and Monte-Carlo simulation which make it inevitable for the implementation of random number generator.

Applications should use as much as possible the techniques and existing libraries for high quality and cryptographic RNGs.

  • random() of JavaScript, which usually ranges 0 and less or greater than 1, is usually implemented with xorshift128+ (or with a variant) in Firefox, V8 engine, and other current browsers. The math.random mostly uses an implementation-dependent strategy or algorithm.
  • The general random number generators of the recent versions of Ruby and Python implement Mersenne Twister which isn’t preferred for high-quality RNGs.
  • Use getinstancestrong() in Java 8 and later but in Java versions earlier than 8 just call securerandom.getinstance(“NativePRNGNonblocking”) and if it’s unsuccessful, use securerandom.getinstance(“NativePRNG”).
  • The .NET Framework System.Random classes aren’t considered high-quality RNGs as they use the seed of at most 32 bits. Subclasses of the Random class can be implemented as high-quality RNGs.
  • Javascript’s util.random class isn’t considered a high-quality RNG as it uses a 48-bit seed although java.util.random subclass can be implemented as a high-quality Random Number Generator.

Any of the pseudo RNG algorithms can be implemented in hardware. The linear shift feedback register is the simplest and commonly used type. Just take a shift register then tap some of the bits. Proceed to munge them then feed them back to the shifter input.

There is a key for choosing the bits to be tapped and also shows how to combine them and generally, prime number bits and a non linear logic transform and fairly distributed e.g. XOR are good selections.

[mashshare]