(PHP 8 >= 8.2.0)

Random\Engine\Xoshiro256StarStar::__constructConstructs a new xoshiro256** engine


public Random\Engine\Xoshiro256StarStar::__construct(string|int|null $seed = null)


Cette fonction est actuellement non documentée ; seule la liste des arguments est disponible.

Liste de paramètres


How the internal 256 bit (32 byte) state consisting of four unsigned 64 bit integers is seeded depends on the type used as the seed.

Type Description
null Fills the state with 32 random bytes generated using the CSPRNG.
int Fills the state with four consecutive values generated with the SplitMix64 algorithm that was seeded with seed interpreted as an unsigned 64 bit integer.
string Fills the state by interpreting a 32 byte string as four little-endian unsigned 64 bit integers.

Erreurs / Exceptions


Exemple #1 Random\Engine\Xoshiro256StarStar::__construct() example

// Uses a random 256 Bit seed.
$e = new \Random\Engine\Xoshiro256StarStar();

$r = new \Random\Randomizer($e);

Exemple #2 Deriving a seed from a chaîne de caractères

= "My string seed";

// Hash the string with SHA-256 using binary output to turn the
// $string into a 256 Bit seed. Using the same string will result
// in the same sequence of randomness.
$e = new \Random\Engine\Xoshiro256StarStar(
hash('sha256', $string, binary: true)

bin2hex($e->generate()), "\n";

L'exemple ci-dessus va afficher :

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top