CryptRandom()

Syntax

Result = CryptRandom(Maximum)
Description
Returns a random number (integer) which lies between (and including) 0 and the Maximum value from the cryptographic safe pseudorandom number generator.

Parameters

Maximum The maximum value to be returned by the function. 'Maximum' may not exceed the positive long value: 2147483647.

Return value

Returns the generated random number.

Remarks

The generator has to be opened first with the OpenCryptRandom() command.

Important: Using a 'Maximum' value which is not one less than a power of two will cause certain numbers to be more likely than others which could be used for a statistical attack. This is the result of dividing the generated random number to fit the specified range.

To generate larger amounts of random data, use the CryptRandomData() function. To generate random numbers from the faster but not cryptographic safe pseudorandom number generator, use the Random() function.

See Also

OpenCryptRandom(), CryptRandomData(), CloseCryptRandom(), Random()

Supported OS

All

<- CloseCryptRandom() - Cipher Index - CryptRandomData() ->