Re: [RFC] [Under Discussion] Random Extension 4.0
| From: | Tim Düsterhus | Date: | Fri, 18 Feb 2022 10:18:17 +0000 |
| Subject: | Re: [RFC] [Under Discussion] Random Extension 4.0 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117060@lists.php.net to get a copy of this message | ||
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.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 $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);