Hawkynt

MLCG (Multiplicative Linear Congruential Generator)

The Multiplicative Linear Congruential Generator is a simplified variant of LCG using only multiplication (no additive constant). It uses the formula X(n+1) = (a * X(n)) mod m. MLCG was one of the earliest PRNGs, introduced by D. H. Lehmer in 1951. While simple and fast, it has poor statistical properties and must never be used for cryptographic purposes.

Properties

Property Value
Category Random Number Generators
Sub-category Pseudorandom Number Generator
Security status πŸŽ“ Educational Only
Complexity Beginner
Inventor D. H. Lehmer
Year 1951
Origin πŸ‡ΊπŸ‡Έ United States
Source algorithms/random/mlcg.js

Parameters

Parameter Supported values
Seed sizes 1 byte (8 bits) to 16 bytes (128 bits)

Capabilities

Flag Value
IsDeterministic Yes
IsCryptographicallySecure No

Security

Status: πŸŽ“ Educational Only

No vulnerabilities are recorded for this implementation.

Documentation

References

Test vectors

4 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.

Vector 1 β€” MINSTD (Park-Miller MLCG) a=16807, m=2^31-1, seed=1 - First 10 values

Field Value
seed 00000001
multiplier 000041a7
modulo 7fffffff
outputSize 40
input null
expected 000041a710d63af160b7acd93ab50c2a 4431b7821c06dac806058ed856e509fe 56f32f4377a4044d

Vector 2 β€” MINSTD (Park-Miller MLCG) - 10,000th value should be 1043618065

Field Value
seed 00000001
multiplier 000041a7
modulo 7fffffff
count 10000
outputSize 4
input null
expected 3e345911

Vector 3 β€” MLCG with a=48271, m=2^31-1, seed=1 - First 5 values

Field Value
seed 00000001
multiplier 0000bc8f
modulo 7fffffff
outputSize 20
input null
expected 0000bc8f0ae257e24cf91f467220517d7be5f8f1

Vector 4 β€” Implicit modulo (2^64) with C# default multiplier, seed=12345

Field Value
seed 0000000000003039
multiplier 5851f42d4c957f2d
modulo (empty)
outputSize 40
input null
expected 0807dc721521c10529e75c5d499968e1 47c1c8e2e1f40e8d6f3cc8211f2f81c9 f12741ce42b98755

← All algorithms