Integrated crypto

Adrian Fisher mobiletiw at fishersinter.net
Thu Apr 1 08:14:13 PST 2004


It has been a long time since i have used C but shouldn't you seed it first?

A

Robert Connolly wrote:

>Anyway. This is an example in http://www.xs4all.nl/~hanb/software/
>arc4random.tar.bz2
>
>#include <stdlib.h>
> int main(void) {
>     int byte1, byte2, byte3;
>         byte1 = random() % 256;
>         byte2 = random() % 256;
>         byte3 = random() % 256;
>         printf("#%02x%02x%02x\n", byte1, byte2, byte3);
>  }
>
>random() can be replaced with rand() too. The output from this is not random, 
>its the same over and over. Why isn't rand() random?
>
>  
>




More information about the hlfs-dev mailing list