Rash64: The Fast Insecure Random Number Generator Function

Douglas Crockford
2018-03-07

Rash64 is a fast but insecure random number generator function. It is an adaptation of Fash64. It hashs a sequence of integers, returning a random number at each step.

This is an implementation in a mythical language.

def prime_11 := 11111111111111111027
def prime_8 := 8888888888888888881
def prime_3 := 3333333333333333271

# The state of the random number generator function is kept in 3 variables.

var counter: uint64
var result: uint64
var sum: uint64

def rash64_seed(seed: uint64) {
    counter := seed
    result := prime_8
    sum := prime_3
}

def rash64() {
    var high
    var low
    high ; low = (result xor counter) * prime_11
    counter += 1
    sum += high
    result = low xor sum
    return result
}