so although using srand(time(0)) can be used to get truly random numbers, how truly random are they? For example, if one were to call this method at the same time (in this example, if one were to use this command at 51s) each time would the numbers generated be the same??? If so, are the numbers still truly random?? And if this theory is true, how can one generate truly random numbers that cannot repeat based on external variables (e.g., time)?

Using srand(time(0)) -- does calling this at the same time of day or time of computer runtime result in same random number(s)?

8/17/2016 10:01:03 AM

Jason Zeleny

4 Answers

New Answer


srand gives you pseudo-random numbers. They are not truly random. For truly random numbers one has to have a source of events that is unpredictable. As far as I know there are companies that provide(d) special hardware that generates truly random numbers from the random nature of atomic decay.


Let me add to my last answer. Pseudo-random numbers can be made less predictable than in your example. SSH uses user input and multiple computer system events to generate the (pseudo-)random numbers required for the SSH keys.


Gotcha, thanks for the info!


My pleasure, Jason :-)