Function RandomKey() Foundation
Calculates a random character string
RandomKey( <nLen> ) --> cKey
The function returns a character string of the length that is determined by the parameter. This character string may include all characters ranging from Chr(0) to Chr(255).
The function RandomKey() produces a character string of random values. The length is determined by the parameter nLen. If available, the function hereby uses the Cryptoprovider of the operating system which delivers the maximum entropy available.
RandomKey() follows strict cryptographic standards. However, it is slower than the function RandomInt() .
// This sample requires the program to be linked as GUI application.
// (linker switch /PM:PM or GUI=yes in the project file).
PROCEDURE Main()
LOCAL oBmp, nXS, nYS
LOCAL aSize, cBuff
LOCAL cHeader
CLS
aSize := SetAppWindow():currentSize()
nXS := Int( aSize[1] )
nYS := Int( aSize[2] )
// Create Bitmap 24 Bit color depth
oBmp := XbpBitmap():new():create()
oBmp:make(nXS, nYS, , 24)
// Cut Bitmap Header
cHeader := SubStr(oBmp:setBuffer(), 1, oBmp:bufferOffset )
// Append the header with 3 Byte per pixel.
// This is a random RGB value for each pixel
cBuff := cHeader + RandomKey( nXS*nYS*3 )
// Set the buffer and paint
oBmp:setBuffer( cBuff )
oBmp:draw(, {0,0,nXS,nYS})
oBmp:destroy()
wait
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.