CryptRandomData()
Syntax
Result = CryptRandomData(*Buffer, Length)Description
Fills the specified memory buffer with random data from the cryptographic safe pseudorandom number generator.
Parameters
*Buffer The buffer to fill. Length The size of the buffer in bytes.
Return value
Returns nonzero if the random data was generated successfully and zero otherwise.
Remarks
The generator has to be opened first with the OpenCryptRandom() command.
To generate random data from the faster but not cryptographic safe pseudorandom number generator, use the RandomData() function.
Example
*Key = AllocateMemory(16) If OpenCryptRandom() And *Key CryptRandomData(*Key, 16) Text$ = "Generated Key:" For i = 0 To 15 Text$ + " " + RSet(Hex(PeekB(*Key+i), #PB_Byte), 2, "0") Next i CloseCryptRandom() Else Text$ = "Key generation is not available" EndIf MessageRequester("Example", Text$)
See Also
OpenCryptRandom(), CryptRandom(), CloseCryptRandom() RandomData()
Supported OS
All