What's the difference between arc4random and random?

后端 未结 2 1797
小鲜肉
小鲜肉 2020-12-06 13:50

What\'s the difference between arc4random and random?

相关标签:
2条回答
  • 2020-12-06 14:12

    random is known to be predictable and thus not to be used for secure pseudo-random number generation. arc4random is a newer, less predictable pseudo-random number generator. If you are not using it for anything secure, random will work fine.

    0 讨论(0)
  • 2020-12-06 14:28

    Depending on your system, random() may or may not be the old, reliable, and predictable UNIX random(). On modern FreeBSD systems, and Linux 2.6 systems that have the /dev/random device, the default random() implementation reads from /dev/random until it is exhausted. This is likely to produce somewhat better random numbers than any numerical sequence generator, depending on the sources of randomness you've stirred into /dev/random.

    Consulting the documentation (man pages, etc) for the system you are deploying the program on is highly suggested.

    0 讨论(0)
提交回复
热议问题