Rash64: The Fast Insecure Random Number Generator Function

Douglas Crockford
2017-07-24

Rash64 is a fast but insecure random number generator function. It is an adaptation of Fash64.

This is an implementation in a mythical language.

def prime := 9999999999999999961

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

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

def rash64_seed(seed: uint64) {
    result := seed
    sum := 3333333333333333271
    counter := 0
}

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