Initializes the RNG generator with a seed file.
Public Declare Function RNG_Initialize Lib "diCrPKI.dll" (ByVal strSeedFile As String, ByVal nOptions As Long) As Long
nRet = RNG_Initialize(strSeedFile, nOptions)
String specifying a seed file.Long option flags: not used in this release. Specify zero.
long _stdcall RNG_Initialize(const char *szSeedFile, long nOptions);
Long: If successful, the return value is zero; otherwise it returns a nonzero error code.
A seed file of exactly 64 bytes is expected. It must exist and be writable by the user. File locking is used to prevent interference from simultaneous use by others. The seed file is automatically updated by this procedure. Initialization is recommended but not mandatory. The security it adds to the RNG process depends on how secure the seed file is, but it never hurts.
This example shows how to initialize the RNG with a seed file, generate some random data, and then update the seed file.
Dim strSeedFile As String Dim nRet As Long Dim abData() As Byte Dim nDataLen As Long Dim i As Integer strSeedFile = "C:\Test\seed.dat" ' 1. Initialize nRet = RNG_Initialize(strSeedFile, 0) Debug.Print "RNG_Initialize('" & strSeedFile & "') returns " & nRet & " (expecting 0)" ' 2. Generate some random data nDataLen = 24 ReDim abData(nDataLen - 1) For i = 1 To 3 Call RNG_Bytes(abData(0), nDataLen, "", 0) Debug.Print cnvHexStrFromBytes(abData) Next ' 3. Update the seed file nRet = RNG_UpdateSeedFile(strSeedFile, 0) Debug.Print "RNG_UpdateSeedFile('" & strSeedFile & "') returns " & nRet & " (expecting 0)"
RNG_Initialize('C:\Test\seed.dat') returns 0 (expecting 0)
79654D8DA3D30468B95B820E3C5615838A765CA666C68A9D
EB2DA20FC86CC797BCB3D26C9E663736E616EF99DEB56C21
5A3DB035BD374E57649AEE367A7E0156A3045AE0111D47EC
RNG_UpdateSeedFile('C:\Test\seed.dat') returns 0 (expecting 0)
RNG_MakeSeedFile RNG_UpdateSeedFile