DEV Community

Discussion on: [Question] What is random seed?

Collapse
 
recursivefaults profile image
Ryan Latta

As noted by other people, Random number generators are pseudo-random which means they look random.

They all use a "seed" to set the numbers that will appear. Put the same seed in and you'll see the same numbers.

This is really important for two things. First is security and second is testing.

Security often demands a secure generator because if someone malicious can guess the seed they can replay randomness which often a core part of security measures regarding tokens. Once they can replay the numbers they can work the rest.

Testing is the other major benefit a seed provides. If you were coding a thing to simulate dice rolls you would likely want to fix some of the results to confirm things. Pre-defined seeds help with that.