random number

Pedro Gimeno gmpdiscuss at personal.formauri.es
Thu Mar 19 00:48:05 CET 2009


José de Jesús Angel Angel wrote:
> seed= rand();
> gmp_randseed_ui (state,seed);

I forgot to say that it's also possible (even likely) that your C 
library doesn't seed the built-in generator by default, meaning that you 
always get the same value on each invocation.

A better approach in that case would be replacing rand() with 
time(NULL). Just as before, don't use that for cryptographic purposes.

-- Pedro Gimeno


More information about the gmp-discuss mailing list