Generates a random set of byte data suitable for cryptographic keys.
Public Declare Function RNG_Bytes Lib "diCrPKI.dll"
(ByRef lpData As Byte, ByVal nDataLen As Long, ByVal strSeed As String,
ByVal nSeedLen As Long) As Long
nRet = RNG_Bytes(lpData(0), nDataLen, strSeed, nSeedLen)
long __stdcall RNG_Bytes(unsigned char *lpOutput, long nOutBytes, const void *lpSeed, long nSeedLen);
If successful, the return value is zero. If the parameters are invalid, it returns a negative error code.
Public Function rngBytes
(nBytes As Long) As Byte()
Rng.Bytes Method (Int32)
Rng.Bytes Method (Int32, Byte)
Rng.Bytes Method (Int32, String)
static bvec_t dipki::Rng::Bytes (int n)
static Rng.bytestring(n)
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.
VB6/VBA users: for historical reasons, the seed parameter is passed as a String
type
and may contain any 8-bit value including the NUL (zero) value.
The length of the seed must be specified (set nSeedLen as zero to ignore).
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)
Dim i As Integer
For i = 1 To 10
Debug.Print cnvHexStrFromBytes(rngBytes(32))
Next
RNG_BytesWithPrompt RNG_Number