Generate cryptographically secure random numbers in php

后端 未结 16 1651
孤街浪徒
孤街浪徒 2020-11-29 07:39

PHP\'s rand() function doesn\'t give good random numbers. So I started to use mt_rand() which is said to give better results. But how good are thes

16条回答
  •  抹茶落季
    2020-11-29 08:15

    Edit: My comment is no longer valid. Please see the following answer: https://stackoverflow.com/a/31443898/109561


    I'm guessing you're worried about the distribution of mt_rand(). I have tested it and it is very level and both bounds are inclusive.

    I added my test to the comments of the documentation for mt_rand() on the php manual, but it was removed by a silly moderator due to politics that are too long winded to go into here.

提交回复
热议问题