A random number generator is a tool that generates random numbers that are often used in probability theory, statistics, and mathematical analysis. In the mathematical theory of probability, random sequences are often used to generate samples from an underlying continuous probability distribution.

Random number generators are important tools in cryptography and computer security because they can produce seemingly random data that cannot be distinguished from true randomness. A cryptographically secure pseudo-random number generator (or RNG) is a special kind of number generator which generates a stream of bits that can be combined with other streams of bits to produce seemingly unpredictable output.