[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ProgSoc] Randomisation



On Tue, 2 Feb 1999, Matt Beauregard wrote:

> >         srand(time(NULL));
> 
> If there's a possibility that the program will be run twice in the same
> second you might want to combine time() with, say, getpid() to mix
> things up a bit.

This merely initialises the RNG. Probably no need to do it twice in any
given second.

Also, be wary of trying to make an RNG "more random". If you don't know
the maths of what you're playing with, it's better not to try to fiddle
with it. Like encrypting a file for the second time, thinking you're
making the encryption tougher, but the opposite could be happening (and
does happen). That is, the first encryption technique is eroded by the
first. Mind you, this is great for anyone trying to decrypt something
for which they don't have the key.

Peter

------------------------------------------------------------------------
Peter Meric                   pmeric@nospam.cs.usyd.edu.au
                              pmeric@nospam.progsoc.uts.edu.au
                              http://www.progsoc.uts.edu.au/~pmeric

--
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@nospam.progsoc.uts.edu.au.
If you are having trouble, ask owner-progsoc@nospam.progsoc.uts.edu.au for help.

This list is archived at <http://www.progsoc.uts.edu.au/lists/progsoc/>