num = urandom()
val = rand([bytes])
t/f = srand([seed])
The urandom() functions returns a 32-bit random number extracted from /dev/urandom.
With no arguments, the rand() function computes a 32-bit pseudo-random number, starting with a seed value provided in an earlier srand() call, or randomly derived from urandom() if the seed is omitted. A series of rand() calls, starting from the same seed value, will always return the same series of values. This is faster (and adequate for most applications), but is not as crytographically secure as urandom().
The above calls all use the underlying system libraries, which are adequate for most programs, but not for serious cryptology. A call to rand(bytes) uses the gcrypt library to return a string of up to 1024 randomly generated bytes (each in a separate character of the string). If the argument is positive, rand() uses a faster algorithm to return a value which is suitable for a nonce, a session key and most general cryptography. A negative value invokes a very strong random number generator, producing a string more suitable for long term keys. This should be used sparingly, because it takes much longer to compute and also depletes the limited entropy pool resource.
Passwords, Encoding and Encryption.