I am with kotlin creating a password generator and I have come across the seeds but I have never known exactly what function they have, what is the difference between passing a seed to a random function with not passing anything to it? I suppose that internally it already has some, but I have never understood it well.
Pseudo-random numbers and their seed
We are going to start with the conceptual part and saying that the Spanish translation of seed is seed .
A seed is used by a PSEUDO-random number generation algorithm to calculate the next number.
And that is that random number generation functions are, after all, deterministic functions . I quote Wikipedia:
The English Wikipedia article: Pseudorandom number generator starts by saying:
My translation and emphasis of the quoted is:
What does all this mean in practice?
/dev/random
,/dev/urandom
and the like which accumulate entropy from system noise to generate truly random seeds which are then fed to a GNPA to return truly random numbers.Why do we settle for pseudo-random numbers?
For a common computer there is no real way to generate a completely random number. Computers are great at doing calculations that deliver accurate and repeatable results, but the poor processor has nowhere to go when it comes to asking for a simple random number. And it is that random numbers have some statistical characteristics, mainly that their distribution is uniform.
That is why, through the genius of some people, we have arrived at the current state of things. Pseudo-random numbers are good enough to be indistinguishable from truly random numbers.
*nix's approach of capturing entropy , for example, from noise heard by Wi-Fi adapters and other electrical sources is great and the best approach I know of to get unpredictable numbers .