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 applicatio开发者_StackOverflow社区n
- I understand that there are better and more recent ways to generate rand numbers
From Apple's Darwin source code, here is the Mac implementation of rand()
, which should be the same as the one used on iOS. Here also is the random()
implementation. They both appear to be drawn from FreeBSD.
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.
精彩评论