CryptRandomData()

Syntax

Result = CryptRandomData(*Buffer, Length)
Description
Fills the specified memory buffer with random data from the cryptographic safe pseudorandom number generator. 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$)

Supported OS

All

<- CryptRandom() - Cipher Index - DESFingerprint() ->