CryptoSys API Library Manual

RNG_KeyBytes

Generates a random set of byte data suitable for cryptographic keys.

VB6/VBA Syntax

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)

Parameters

abOutput
[out] Byte array of sufficient length to receive the output.
nBytes
[in] Long value of the required key length in bytes.
strSeed
[in] String containing an (optional) user-specified seed to be used by the random number generator. Specify an empty string ("") or NULL to ignore..
nSeedLen
[in] Long specifiying the size of the seed in bytes.

C/C++ Syntax

long _stdcall RNG_KeyBytes(unsigned char *keyArray, long keyLen, const char *seed, long seedlen);

Returns (VB6/C)

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.

.NET Equivalent

Rng.KeyBytes Method (Int32, Byte[])
Rng.KeyBytes Method (Int32, String)

Remarks

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.

Example

    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

See Also

RNG_KeyHex

[Contents] [Index]

[HOME]   [NEXT: RNG_KeyHex...]

Copyright © 2001-11 D.I. Management Services Pty Ltd. All rights reserved.