5
How, using the PHP language, generate a string, preferably with configurable size, random enough to be used in routines dealing with cryptography and that for safety reasons cannot be insufficiently random?
If you propose more than one solution, preferably clarify which one you think is more random, possibly with external additional references. Solutions involving more than one source of randomness generator are also welcome, in particular if accompanied by explanation of advantages, such as reducing problems with an operating system explicitly changed by an NSA of life to generate less chaos when producing randomness.
Even if two people propose the same code, if one of these explains better or proves with real examples the dispersion of values, it will be considered as the best answer. It is not enough to copy and paste code, you should discuss why it is a good solution.
Solutions that directly access an operating system resource, using for example shell_exec
, although they are not desirable, they are also welcome to explain in what context they would be advantageous like older PHP versions or that they do not have a specific PHP module that would allow using a more appropriate routine.
maybe you should put the code of this routine in your answer, it is easier for people to see and if one day the link fails your answer will still be valid.
– Math
I agree with you that you could have set an example, but you didn’t have time to write and test a routine, which could become outdated with time and updates in the PHP API. The link is directly to the PHP API page, from where it is not allowed to reproduce the content of the site, so you could not copy and paste the example here. But I thank you for your suggestions and I will take it into consideration for my next responses.
– Vitor Arbex
@Math There is another license problem, all content placed on the site is automatically licensed by cc by-sa 3.0, unless the code was made by me, it could only post some ready code on the web if the license was compatible. What in the case of the PHP site is not, because the content of their site is Copyright and is not allowed to copy all or part of it. Therefore, care is needed when posting third party code here.
– Vitor Arbex