Date: Wed, 15 Nov 2000 13:49:58
Mike Brennan to Kathy Sanley:
Recall that several months ago I helped you with random number generation for (I believe) generating PINs. While the solution I came up with was ok as a stopgap measure, I was not particularly happy with it. I've since come up with a better way to generate random numbers for future applications. (It would also be worthwhile to modify the original application to use this new procedure).
I recommend that the procedure I describe here ALWAYS be used instead of the INFO/BASIC RND() function. That's because this new procedure uses a very secure seed and also, unlike RND(), uses a cryptographically secure pseudorandom number generator.
Please forward this email to whomever you deem appropriate.
There are two subroutine calls you need to use:
Doing:
is semantically equivalent to doing:
See the description of RND() in the INFO/BASIC manual for more info.
Note that the generator used here is self-seeding; you need not and cannot specify a seed. Also note that the seed is always unique, so you can't use PSU.RND() to generate a repeatable sequence as you can with RND().
A generator is automatically created, initialized, and seeded the first time you call PSU.RND(). The generator remains in memory and uses system resources even when you're not using it--even after your program finishes. So once you have finished your random number generation, it's a good idea to call RAND.DESTROY to free up those resources. A new generator will then be created next time you call PSU.RND.
EXAMPLE: The following program prints 6-digit pseudorandom numbers between 100000 and 999999 inclusive: