Is it possible to predict rand(0,10) in PHP?

后端 未结 6 1690
栀梦
栀梦 2020-12-15 06:46

I have a script where I use the rand function in PHP. Now I read some ghost stories that its real easy to predict those outcomes. Is this possible from the client-side?

6条回答
  •  太阳男子
    2020-12-15 07:37

    From the rand manual:

    A pseudo random value between min (or 0) and max (or getrandmax(), inclusive).

    So, random is not random, but pseudo random. If you know how the caluclation is done, and know the initial value one can predict (calculate) the next value.

    If you need a true random value, you need a other algorithm. Based on white noise, for example.

提交回复
热议问题