Xorshift32 is the simplest xorshift PRNG using a single 32-bit state with three XOR-shift operations. Invented by George Marsaglia in his seminal 2003 paper on xorshift generators. Extremely fast with period 2^32-1, suitable for simulations and gaming.
| Property | Value |
|---|---|
| Category | Random Number Generators |
| Sub-category | Xorshift Family |
| Security status | π Educational Only |
| Complexity | Beginner |
| Inventor | George Marsaglia |
| Year | 2003 |
| Origin | πΊπΈ United States |
| Source | algorithms/random/xorshift32.js |
| Parameter | Supported values |
|---|---|
| Seed sizes | 1 byte (8 bits) to 4 bytes (32 bits) |
| Flag | Value |
|---|---|
IsDeterministic |
Yes |
IsCryptographicallySecure |
No |
Status: π Educational Only
No vulnerabilities are recorded for this implementation.
6 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.
Vector 1 β Seed 1: First 5 outputs (20 bytes) - verified against reference implementation
| Field | Value |
|---|---|
seed |
00000001 |
outputSize |
20 |
input |
null |
expected |
00042021040806019dcca8c51255994f8ef917d1 |
Vector 2 β Seed 12345: First 5 outputs (20 bytes) - common test seed
| Field | Value |
|---|---|
seed |
00003039 |
outputSize |
20 |
input |
null |
expected |
c6e5747a652a09afa7e08fa0748e41ea2ad8a9d3 |
Vector 3 β Seed 0 (defaults to 1): First 5 outputs - zero seed handling
| Field | Value |
|---|---|
seed |
00000000 |
outputSize |
20 |
input |
null |
expected |
00042021040806019dcca8c51255994f8ef917d1 |
Vector 4 β Seed 0xFFFFFFFF (max 32-bit): First 5 outputs (20 bytes) - edge case
| Field | Value |
|---|---|
seed |
ffffffff |
outputSize |
20 |
input |
null |
expected |
0003e01ffc07fdff74bb9843f1cc88da7a28ee91 |
Vector 5 β Seed 42: First 8 outputs (32 bytes) - answer to everything
| Field | Value |
|---|---|
seed |
0000002a |
outputSize |
32 |
input |
null |
expected |
00ad4528a90a34ac1c67af03d970c3c0e01ccbc455ea99b6dd5701d890eff2ae |
Vector 6 β Seed 2^31 (0x80000000): First 5 outputs - high bit set
| Field | Value |
|---|---|
seed |
80000000 |
outputSize |
20 |
input |
null |
expected |
8008400089088484aa914148d5b8029468b7e441 |