RNG_Bytes generates a random set of byte data suitable for cryptographic keys.
Public Declare Function RNG_Bytes Lib "diCrPKI.dll"
(ByRef abData As Byte, ByVal nDataLen As Long, ByVal strSeed As String,
ByVal nSeedLen As Long) As Long
nRet = RNG_Bytes(abData(0), nDataLen, strSeed, nSeedLen)
Byte array to receive the random data.Long specifying the required length in bytes.String containing "user-supplied entropy" to be used by the random number
generator. Specify an empty string ("") or NULL to ignore.Long specifying the length of the seed string.
long _stdcall RNG_Bytes(unsigned char *lpOutput, long nOutputLen, const void *lpSeed, long nSeedLen);
Long: If successful, the return value is zero.
If the parameters are invalid, it returns a negative error code.
Rng.Bytes Method (Int32)
Rng.Bytes Method (Int32, Byte)
Rng.Bytes Method (Int32, String)
The maximum number of random bytes that can be requested in one call is 65,536 (64 kB).
If you need more (!), make repeated calls.
In the VB6 interface, for historical reasons, the seed ("user-supplied entropy") parameter is passed as a String type.
This string is allowed contain NUL (zero) characters.
If the RNG fails its FIPS-140 continuous test, the DLL process will be terminated. There is no option to avoid this, but the chances of such a failure under normal conditions are absolutely miniscule - about 1 in 9 quintillion (billion billion billion). See Random Number Generator for more information on the RNG, entropy, and its compliance with the relevant standards.
Dim abData() As Byte
Dim nDataLen As Long
nDataLen = 16
ReDim abData(nDataLen - 1)
Call RNG_Bytes(abData(0), nDataLen, "", 0)
Debug.Print cnvHexStrFromBytes(abData)
RNG_BytesWithPrompt RNG_Number