Hi

On 2/18/22 04:05, Go Kudo wrote:
As for your question, buffering the output can lead to counter-intuitive
behavior in code like the following.

```php
<?php

$engine = new \Random\Engine\Xoshiro256StarStar(1234);
$randomizer = new Randomizer($engine);

// Retrieve only 16 bits (the remaining 48 bits will be buffered in
Randomizer)
$str = $randomizer->getBytes(2);

// Generate a new 64 bits (to waste)
$engine->generate();

// Retrieve 64 bits (first 48 bits from buffer, but last 16 bits newly
generated)
// numerical continuity will be lost.
$str2 = $randomizer->getBytes(8);
```

Personally I'd say by using the engine itself or using a different Randomizer it's clear that any kind of guarantees regarding the result no longer hold, because the state will be modified.

I've also seen your other email and will reply to it as well.

Best regards
Tim Düsterhus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to