Generate cryptographically secure random numbers in php

后端 未结 16 1681
孤街浪徒
孤街浪徒 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:27

    In what way is mt_rand() "bad"?

    For example: If it favors a certain number. Lets say mt_rand(1, 10) favours low numbers in the range, ie "1" and "2" occurs on average more than 10% each. Then your "improvement" would still suffer from the same problem.

    Selecting a random number out of a faulty sequence will still be faulty.

提交回复
热议问题