Is it possible to calculate a seed from a given list of numbers, such that this seed will cause a number-generating function (like rand()
) to output this list of numbers?
And, at which point does it become unlikely that such a seed can be found at all (if the input list gets too large, for example)?
It doesn’t have to be rand()
, of course. Any generating function would do, and would be known at the time of the calculation.
For example:
int seed;
int myRand() // RAND_MAX assumed to be 32767
{
seed = seed*1103515245 + 12345;
return (seed/65536) % 32768;
}
// given numbers: 19098, -31546, 32637, 21910, -27300
// use black magic maths to find seed 75235
int main() {
seed = 75235;
printf("%dn", myRand()); // 19098
printf("%dn", myRand()); // -31546
printf("%dn", myRand()); // 32637
printf("%dn", myRand()); // 21910
printf("%dn", myRand()); // -27300
return 0;
}
Thanks!