Generates a random set of byte data suitable for cryptographic keys.
Public Declare Function RNG_KeyBytes Lib "diCryptoSys.dll"
(ByRef abOutput As Byte, ByVal nBytes As Long,
ByVal strSeed As String, ByVal nSeedLen As Long) As Long
nRet = RNG_KeyBytes(abOutput(0), nBytes, strSeed, nSeedLen)
Byte array of sufficient length to receive the output.Long value of the required key length in bytes.String containing an (optional) user-specified seed to be
used by the random number generator. Specify an empty string ("") or NULL to ignore..Long specifiying the size of the seed in bytes.
long _stdcall RNG_KeyBytes(unsigned char *keyArray, long keyLen, const char *seed, long seedlen);
Long: Always returns zero.
If the function fails its continuous random number generator test, a critical error will occur.
See Self Tests for more details.
Rng.KeyBytes Method (Int32, Byte[])
Rng.KeyBytes Method (Int32, String)
The seed strSeed is optional and is added to the automatic seed values generated internally. The seed cannot directly affect the value of the output; it will just ensure that it will be different.
Dim abKey() As Byte
Dim nRet As Long
Dim nKeyBytes As Long
Dim i As Integer
nKeyBytes = 24
ReDim abKey(nKeyBytes - 1)
' Generate three successive 192-bit random keys with no seeding
For i = 1 To 3
nRet = RNG_KeyBytes(abKey(0), nKeyBytes, "", 0)
Debug.Print cnvHexStrFromBytes(abKey)
Next