Core Function RandomSeedSet

From Sputnik Wiki
Jump to: navigation, search
RandomSeedSet( <seed> )

Contents

Description

Set the seed of Sputniks random number generator

Parameters

seed

New seed to use for all future random number generations Sputnik does.

Return Value

Success: Returns a cryptographically strong random number/binary array.

Failure: Return null.

Remarks

You can use RandomSeed() to generate a cryptographically secure seed or provide your own.

Example

Set Sputniks RNG seed to a cryptographically secure random number

$Seed = RandomSeed();
RandomSeedSet($Seed);
say RandStr(10);
// Prints
// esehltkajk

Changing Sputniks RNG seed will cause all functions that use the RNG to be effected for example here RandStr() is returning the same text every time since we keep setting the seed to same value

$i = 0;
while($i++ < 3)
{
	RandomSeedSet(777);
	say RandStr(10);
}
// Prints
// qfqg5678k3
// qfqg5678k3
// qfqg5678k3
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox