PHP port of the (non-cryptographic) Alea pseudo-random number generator
alea.php is a port of the non-cryptographic Alea pseudo-random number generator to PHP.
This package is available on Packagist:
$ composer require wikimedia/alea
use Wikimedia\Alea\Alea; $prng = new Alea(); // add an optional seed parameter $nextRandom = $prng->random(); // or ->uint32() or ->fract53()
We also have the ability to sync up two Alea PRNGs (even across platforms)
$prng1 = new Alea(200); $prng1->random(); $prng1->random(); $prng2 = Alea::createWithState( $prng1->exportState() ); assert( $prng1->random() === $prng2->random() ); assert( $prng1->random() === $prng2->random() ); assert( $prng1->random() === $prng2->random() );
Read more on Johannes' site.
The port to PHP was initially done by C. Scott Ananian and is (c) Copyright 2019-2021 Wikimedia Foundation.
Both the original alea codebase and this port are distributed under the MIT license; see LICENSE for more info.