This was questions asked in one of the interviews that I recently attended.
As far as I know a random number between two numbers can be generated as follows
Here I am suggesting some sources with comment may be you find helpful:
/proc
file data: On Linux system. I feel you should use this.
/proc/sys/kernel/random:
This directory contains various parameters controlling the operation of the file /dev/random
.
The character special files /dev/random
and /dev/urandom
(present since Linux
1.3.30
) provide an interface to the kernel's random number generator.
try this commads:
$cat /dev/urandom
and
$cat /dev/random
You can write a file read function that read from this file.
Read (also suggests): Is a rand from /dev/urandom secure for a login key?
`