Randograms

PRNG name

Description


  
Seed differential coordinate analysis on bit
Color analysis

AES-CTR

The Advanced Encryption Standard in Counter mode. Now used by macOS and Windows.

    state.counter++;
    let matrix = state.counter;
    for (let i = 0; i < 10; i++) {
      matrix = SubBytes(matrix);
      matrix = ShiftRows(matrix);
      if (i < 9) { matrix = MixColumns(matrix); }
      matrix = AddRoundKey(matrix, state.key, i);
    }
    return matrix;
    

arc4random

Also known as the RC4 cipher. Formerly used by macOS. Look for bit 0.

    i = (i + 1);
    j = (j + state[i]);
    [state[i], state[j]] = [state[j], state[i]];
    return state[(state[i] + state[j])];
    

XorShift128+

As used by Firefox, Chrome, Safari. Look for similar early clustering in bits 11 thru 14.

    let s1 = this.state[0], s0 = this.state[1];
    this.state[0] = s0;
    s1 ^= (s1 << 23n) & this.mask64;
    s1 ^= s1 >> 17n;
    s1 ^= s0;
    s1 ^= s0 >> 26n;
    this.state[1] = s1;
    return (s0 + s1) & this.mask64;
    

drand48

As used by Java. Look for bits 16+.

    this.state = (this.state * 0x5DEECE66Dn + 0xBn) & this.mask;
    return Number(this.state >> 16n);
    

Lehmer-128

Simple MCG on a 128-bit number. Look for bits 0 thru 9.

    this.state = (this.state * 0xda942042e4dd58b5n) & ((1n << 128n) - 1n);
    return this.state >> 64n;
    

Alea

Float multiplication. Look for bit 5.

    const s = this.state;
    const t = 2091639 * s[0] + s[3] * 2.3283064365386963e-10; // 2^-32
    s[0] = s[1];
    s[1] = s[2];
    return s[2] = t - (s[3] = t | 0) * 0x100000000;
    

RomuTrio32

Multiplication, cascade subtraction and rotation. See recurrent point at top left across seed flips.

    const s = this.state;
    s[0] = 3323815723 * s[2];
    s[1] = rol(s[1] - s[0], 6);
    s[2] = rol(s[2] - s[1], 22);
    return s[0];
    

SFC32

Small fast counter-based.

    const s = this.state;
    const r = s[0] + s[1] + s[3];
    s[3]++;
    s[0] = s[1] ^ s[1] >>> 9;
    s[1] = s[2] + (s[2] << 3);
    s[2] = (s[2] << 21 | s[2] >>> 11) + r;
    return r;
    

Combit

Segregated rotation and addition.

    const rot = counter & 31;
    for (let i = 4; i > 0; i--) {
      state[i] = ror(state[i], rot) + state[i-1];
    }
    state[0] = ror(state[0], rot) + counter++;
    return state[4];
    

Fabira

Fast big randomness.

    var s = this.state, t = (s.table[s.byte_index++] += s.diffuser);
    return (s.diffuser += rotate_right(t, 11)) ^ t;