random number

Dennis Clarke dclarke at blastwave.org
Thu Mar 19 01:18:35 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.

Would it not be better to just read bits from /dev/random ?

dclarke at vesta:~/build/2009$ dd if=/dev/random bs=16 count=1 | od -Ax -t x1
1+0 records in
1+0 records out
16 bytes (16 B) copied, 0.0007 s, 22.9 kB/s
000000 3d ec 89 09 01 42 9a a8 5f 83 9c c9 9c 81 06 c9
000010


-- 
Dennis Clarke



More information about the gmp-discuss mailing list