Gus Gassmann <(E-Mail Removed)> writes:

> So now I am looking for a random number generator with the following

> properties:

>

> 1. Portability.

> 2. Random starting points.

> 3. Replicability on demand.

>

> I presume this means that I would seed the RNG based on the clock, but

> keep a copy of the seed that I could optionally use at the start in

> case I found a problem on a previous run.

>

> Statistical properties are of lesser importance.
Replicability suggests a determinisic process: random starting points

are then your own problem of choosing a seed in some acceptable way.

There are a number of very simple and fast cryptographic-quality

generators out there (though you don't mention performance as being a

consideration at all).

Rivest's RC4 is extremely simple, and though it has some minor biases

seems adequate for non-cryptographic use if you can tolerate its

octet-at-a-time output.

Bernstein's Salsa20/8 is simple, fast, and seems very secure; it's also

seekable, which may or may not be of interest.

For non-cryptographic applications, I usually use Knuth's lagged

Fibonacci generator, which wants a lot of seed material; for this, I use

a linear congruential generator of my own devising.

I don't have an implementation of Salsa20/8, but you can surely find the

code online; the others are implemented in my Catacomb library, in

(pedantically) portable C:

http://git.distorted.org.uk/~mdw/catacomb/tree
available under the LGPL (see {rc4,fibrand,lc}.[ch]). Since this is for

testing purposes, I imagine the code won't in fact be distributed at all

and LGPL will therefore be acceptable. If I'm wrong about this, send me

mail: I'm willing to be generous with small portions of the library on a

case-by-case basis.

-- [mdw]

--

comp.lang.c.moderated - moderation address:

(E-Mail Removed) -- you must

have an appropriate newsgroups line in your header for your mail to be seen,

or the newsgroup name in square brackets in the subject line. Sorry.