Initializes the RNG generator with a seed file.
VB6/VBA
Debug.Print "Testing RNG_Initialize ..." Dim strSeedFile As String Dim nRet As Long Dim abData() As Byte Dim nDataLen As Long Dim i As Integer strSeedFile = ".\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_KeyBytes(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)"
Output
Testing RNG_Initialize ...
RNG_Initialize('.\seed.dat') returns 0 (expecting 0)
4BABB91D37EA2E7DE0C5938A4664EA3837C38861D4631BDC
B4B45B89475521AC7838072F6011955C7814E0AAD33B829C
66F3A09DFE35644FDD7EAE7C29CFE8CBA03D48E81E644F80
RNG_UpdateSeedFile('.\seed.dat') returns 0 (expecting 0)
VB.NET
Console.WriteLine("Testing RNG_Initialize ...")
Dim strSeedFile As String
''Dim nRet As Integer
Dim abData() As Byte
Dim nDataLen As Integer
Dim i As Integer
Dim fIsOK As Boolean
strSeedFile = ".\seed.dat"
' 1. Initialize
fIsOK = Rng.Initialize(strSeedFile)
Console.WriteLine("RNG_Initialize('" & strSeedFile & "') returns " & fIsOK & " (expecting TRUE)")
' 2. Generate some random data
nDataLen = 24
''ReDim abData(nDataLen - 1)
For i = 1 To 3
abData = Rng.KeyBytes(nDataLen, "")
Console.WriteLine(Cnv.ToHex(abData))
Next
' 3. Update the seed file
fIsOK = Rng.UpdateSeedFile(strSeedFile)
Console.WriteLine("RNG_UpdateSeedFile('" & strSeedFile & "') returns " & fIsOK & " (expecting TRUE)")
[Contents]