Creates a new instance of the deterministic pseudorandom number generator (PRNG) with the specified seed. Given the same seed, the generator will always produce the same results for the same calls in the same order.
The PRNG is based on the cryptographically secure Xoodoo permutation in Extendable-Output Function (XOF) with 256-bit capacity.
The implementation is subject to change in future versions until further notice, with the aim of eventually stabilizing it.
seeded(seed)
seed
A string or a typed array.
An object with the same methods as random, but with an implementation that expands the seed into a deterministic sequence of random numbers instead of generating them randomly.
// Initialize the first PRNG.
prng1 = random.seeded("first")
print("first:", prng1.int(100))
print("first:", prng1.int(100))
print("first:", prng1.string(4))
// Initialize the second PRNG.
prng2 = random.seeded("second")
print("second:", prng2.int(100))
print("second:", prng2.int(100))
print("second:", prng2.string(4))
// Initialize the third PRNG with the same seed as the first one.
prng3 = random.seeded("first") // same seed
print("third:", prng3.int(100)) // same result as prng1
print("third:", prng3.int(100)) // same result as prng1
print("third:", prng3.string(4)) // same result as prng1
first: 37
first: 15
first: lsxL
second: 45
second: 2
second: x4kY
third: 37
third: 15
third: lsxL