How to use the PHP language to generate a string, preferably with configurable size, random enough to be used in routines that handle encryption and that for security reasons can not be not too random?
If you propose more than one solution, preferably specify which one you think is most random, possibly with additional external references . Solutions that involve more than one source of randomness are also welcome, especially if accompanied by an explanation of advantages, such as reducing problems with an operating system explicitly altered by a NSA of life to generate less chaos when it comes to 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. Do not just copy and paste code, you should give it a try because it's a good solution.
Solutions that directly access an operating system resource, for example usingshell_exec
, although not desirable, are also welcome with an explanation of what context would be advantageous, such as older versions of PHP or not having a specific PHP module that would allow you to use a more appropriate routine.