iphone - What is the exact algorithm for Objective-C's built-in rand() function?

If you have a client/server application and you want to duplicate the same series of random numbers that the rand() function produces on the client, but on a server, what is the algorithm/pseudo code? The client and server would be given the same seed (srand() on the client).

Thank you!

Please note:

  • Is this not known? If so, please state
  • Can it be reverse engineered? If so, please post, unless any license agreements would prevent you from doing so. In other words, don't do anything illegal
  • I am not interested in design suggestions for the client/server application
  • I understand that there are better and more recent ways to generate rand numbers

2 Answers

  1. Jeffery- Reply

    2019-11-13

    Most C compilers I've seen use a linear congruential random number generators for their rand() function. You don't need to reverse engineer it: it's open source.

    BTW if this is the basis of some sort of encryption/security system. It's a really bad idea.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>