Re: /dev/random vs. /dev/urandom

Robert Love
2005-01-07T19:49:04Z

On Fri, 2005-01-07 at 14:05 -0500, Ron Peterson wrote:

> read( fd, dat, RAND_LEN );
> for( i = 0; i < RAND_LEN; i++ ) {
> dat[i] = (dat[i] & 0x07) + '0';
> }

Your problem is probably because read() need not actually read RAND_LEN
bytes. Particularly with /dev/random, since it will only return bytes
up to the entropy estimate. But you assume it read RAND_LEN, when those
are unread. And possibly zero. So that is probably your bug.

The AND makes zero sense, either.

Just use dd(1).

Robert Love