Mersenne Twister
Mersenne Twister is a family of deterministic pseudorandom number generators with very long periods, including MT19937 with period 2^19937−1.
Hacking Cryptography
A deterministic pseudorandom number generator family based on recurrences associated with Mersenne primes and designed to provide a very long period.
- How it is used
- Uses MT19937 to implement a practical pseudorandom generator and demonstrate why it fails for cryptographic applications.
- How deep it goes
- Explains state initialization, twisting, tempering, untempering, and full-state cloning, stopping short of the constants’ mathematical derivation.
- Examples
- Demonstrates Go implementation listings, default-seed test vectors, and a cloning test that matches 100 predicted outputs.
- What you can do after
- Diagnose MT19937 misuse, implement its state transformations, and reproduce an output-only state-cloning attack.
Learn C++ by Example
mt19937 is a C++ standard library pseudorandom number engine implementing the Mersenne Twister algorithm with a period of 2^19937−1.
- How it is used
- Generates pseudorandom integers for a guessing game and supports reproducible simulations or tests.
- How deep it goes
- Explains periods, seeds, engines, and distributions, then demonstrates one generated integer without developing the algorithm’s internals.
- Examples
- Uses a deliberately poor alternating generator, a 1–100 integer generator, and a random-number guessing game.
- What you can do after
- Apply it via std::random_device, std::mt19937, and std::uniform_int_distribution to generate bounded integers.
Related concepts
- pseudo-random number generatorkind of · A pseudorandom number generator is a deterministic computational process that uses an initial seed or internal state to produce a sequence with random-like statistical properties.
- std::random_deviceconfigured by · std::random_device is a C++ standard library generator interface that supplies nondeterministic random values when supported by the implementation.
- random number enginekind of · A random number engine is a pseudorandom generator component that produces a deterministic sequence from an internal state and algorithm.
- statehas part · State is information or a configuration describing the condition of a system, entity, or computation at a particular time and potentially influencing subsequent behavior or decisions.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

