Random file of set length
Randy Kaelber
plug-discuss@lists.plug.phoenix.az.us
Wed, 11 Sep 2002 17:16:56 -0700
"Gilbert T. Gutierrez, Jr." wrote:
>
> I actually figured this out as soon as I sent the question out. I used
> /dev/urandom. This question was only to create a garbage file. I really
> did not care how random it was. I am using FreeBSD and for some reason
> /dev/random did not work.
>
Then Matt's answer was best, since you meant you just needed a 5 meg
file, without respect to its contents. /dev/zero is a *very* efficient
character generator. :-)
Let me guess: You used /dev/random and it just "froze up", yes?
/dev/random is a source of high entropy bits in Linux (and in *BSD... as
I recall, Linux borrowed the idea from there) and that entropy is
collected over time. If all the entropy is used, further reads to
/dev/random will block until there's sufficient entropy to satisfy the
request.
Generally, the only time you would want to read /dev/random is when you
need a block of highly unpredictable data for high security cryptography
purposes, such as public/private key generation. /dev/urandom is more
useful for not quite as much entropy, but when you need a higher volume
of random data that is still more unpredictable than an equation/seed
based pseudorandom number generator. They're good for one-time session
keys and the like.
--
Randy Kaelber
Randy.Kaelber@asu.edu
Software Engineer
Mars Space Flight Facility, Department of Geological Sciences
Arizona State University, Tempe, Arizona, USA
"Anarchy is the sure consequence of tyranny; for no power that is not
limited by laws can ever be protected by them." - Milton