Contact Us Today 01642 716680

Pseudorandom Number Generator

Definition: A Pseudorandom Number Generator (PRNG) is an algorithm designed to produce a sequence of numbers that approximates the properties of random numbers. While the numbers generated by a PRNG might appear random, they are computed using a deterministic process and, given the initial state or seed, the same sequence can be regenerated.

Pseudorandom Number Generators are a fundamental component in many aspects of cyber security, particularly in cryptographic applications where they are used to generate cryptographic keys, random nonces, and other elements that rely on unpredictability. The security of the PRNG is critical because if the sequence of numbers it generates can be predicted, it may compromise the security of the cryptographic system it is used to protect.

A strong Pseudorandom Number Generator must pass various statistical tests for randomness and also be unpredictable to an attacker who has knowledge of some or even many preceding numbers in the sequence. However, Pseudorandom Number Generators are not suitable for all applications due to their deterministic nature; where true randomness is required, True Random Number Generators (TRNGs) are needed.

Key Characteristics:

  • Deterministic: PRNGs are predictable if the initial seed value is known.
  • Efficient: They can quickly generate long sequences of numbers.
  • Repeatable: Given the same seed, a PRNG will always produce the same sequence of numbers.
  • Statistical Randomness: High-quality PRNGs produce sequences that pass tests which suggest randomness, despite being generated by deterministic processes.

Code example of a Pseudorandom Number Generator

Notes: The random library in python can be used to generated Pseudorandom Numbers


  • Real-World Example: A PRNG is used in an SSL/TLS handshake to generate random numbers that contribute to the session keys used to encrypt web traffic.
  • Hypothetical Scenario: A video game developer uses a PRNG to generate unpredictable patterns of enemy behaviour to enhance the game’s difficulty and ensure gameplay variety.

Related Terms:

  • Random Number Generator (RNG): A broader term that includes any mechanism or algorithm for generating random numbers, including TRNGs and PRNGs.
  • Seed Value: The initial input value used by PRNGs to start generating a pseudo-random sequence.
  • Cryptography: The practice of secure communication, which often relies on PRNGs for generating encryption keys that appear random.

Learn better by watching a video? Here is a YouTube video explaining the concept.

What is the OWASP Top 10: Download our flash cards to find out.

Inside you will find a description of the most common web vulnerabilities.

Contact us

Get a free, no obligation quote from one of our expert staff.