Does the size of the seed (in bits) for a PRNG make any difference? Does the size of the seed (in bits) for a PRNG make any difference? python-3.x python-3.x

Does the size of the seed (in bits) for a PRNG make any difference?


The size of the seed is important at least in the sense that it is ideally equal to the state length of the PRNG. Although seeds that have been used in common practice are 32 or 64 bits long, such seeds are generally appropriate only if the underlying PRNG's state length is 32 or 64 bits, respectively. Many modern PRNGs have longer state lengths, though. (In general, the greater the variety of seeds, the greater the variety of random number sequences a PRNG can generate.)


The seed is only important from a predictability perspective. This seed has no impact on how "random" the numbers are that come out of the PRNG after it's seeded.

If you need your numbers to be unpredictable, as in if someone could figure out your seed and generate the same sequence of numbers That Would Be Bad, such as if you were running a casino for real money or generating private keys for cryptography, then you cannot use tiny seeds.

You must use unpredictable, highly random sources of "entropy" to seed your PRNG. These are often provided by your operating system (e.g. /dev/rand) but many cryptographic-grade libraries also provide really good random number generator functions because of how important those functions are.

The classic srand(time(NULL)) call, which seeds the PRNG in C with the epoch time in seconds, shows up all over the place. If you can guess what time the program was started at you can determine, precisely, what numbers come out of their generator. You can "predict" everything about that PRNG. Since there's only ~2.1 billion possible times, you could even brute-force this. If you know +/- a few hours it's only a few thousand possibilities to try, making it even more trivial.

Remember the "P" in PRNG stands for "pseudo" which means "fake". The numbers look random but are procedurally generated and the only way you can prevent people from discovering what those numbers are is by seeding your PRNG properly.