seeding arc4random() in iOS

andrewz picture andrewz · Nov 23, 2010 · Viewed 9.2k times · Source

From what I can gather arc4random() generates much better random numbers than rand() does, however I haven't seen a way to seed it, and I would like to just like using srand(). Is there a way?

Answer

Joey picture Joey · Nov 24, 2010

That's not what arc4random is designed to do. As the documentation states:

The arc4random() function provides a high quality 32-bit pseudo-random number very quickly. arc4random() seeds itself on a regular basis from the kernel strong random number subsystem described in random(4).

Since it is re-seeds itself from an entropy source anyway, you gain nothing by seeding it manually, and in fact, such a method does not exist.