3 ms·
Yeah. Random is hard. BUT when you actually already have far better implementation of PRNG, namely md_rand in PHP, there really is no excuse for defaulting to
by zokier 17y ago
Yeah. Random is hard.
BUT when you actually already have far better implementation of PRNG, namely md_rand in PHP, there really is no excuse for defaulting to broken behavior.
- jacquesm 17y agoThat may actually have to do with not upsetting peoples unit tests that depend on this 'broken behavior'. Let's say someone wrote an extensive body of statistical software that gets tested with the known input from the PRNG in php, if you then change the random number generator all the output will be different. Or if someone used the PRNG in PHP to encrypt a bunch of data replacing it would break the decrypt function leaving the user with inaccessible data.
- rbanffy 17y agoTrusting the broken behavior of a broken random-number generator is hardly the best approach to encrypting data. Anyone who writes a test that depends on the predictability of a random number generator is in for a huge disappointment when the data is to be decrypted. Why not do it using a proper crypto library?
- jacquesm 17y agoIt was two examples, one for 'test' data, one for the passwords example. The first showed a series of cases that have been saved to check if code has been inadvertently broken. The second example was about data stored in a database that depends on the functioning of the PRNG in a predictable way for its use. Both examples are 'contrived', just theoretical situations to show you that it is possible to break stuff by changing the function of a piece of code that implements a language feature. The general message was: if you can remain backwards compatible then that is probably a good thing because there are bound to be use cases for your code that you can't think of that will have huge consequences. So I think the PHP team did the right thing here in making a better random number generator available besides the old one. Legacy data and software is always a pain, as soon as you have an installed base of '1' you have a problem. Designers of languages break existing code at their peril. That said, they should have probably implemented a better one right from day 1.
- rbanffy 17y ago"That said, they should have probably implemented a better one right from day 1." I still can't believe it's a good idea not to break behavior that depends on the predictability of a broken implementation of a random number generator. It's not like this code will be broken by fixing the RNG. It was broken from the start.