[REBOL] Re: random implementation
From: holger:rebol at: 8-Feb-2001 7:44
On Thu, Feb 08, 2001 at 10:51:15AM +0000, Chris wrote:
> Allen Kamp wrote:
>
> I haven't run any tests on that yet but what are the differences between
> normal and /secure? And how is the range restriction implemented? For
> example, doing something like
The default algorithm is fast, but probably not suitable for your purposes.
> outvalue = 1 + (calculatedRandom % maxValue)
>
> is less random than
>
> outvalue = 1 + ((calculatedValue * maxValue) / (maximumRandom + 1))
random/secure uses SHA1 as the iterator function. It is not an LCG, and
provides cryptographically strong non-linearity between all bits and
bit combinations, so it should not suffer from the problem you described
above.
--
Holger Kruse
[holger--rebol--com]