CryptoSys API Library Manual

RNG_NonceData

RNG_NonceData returns a random nonce (number used once) as a specified-length byte array. This replaces the RNG_Nonce function from version 2.

VB6/VBA Syntax

Public Declare Function RNG_NonceData Lib "diCryptoSys.dll" (ByRef abOutput As Byte, ByVal nBytes As Long) As Long

nRet = RNG_NonceData(abOutput(0), nBytes)

Parameters

abOutput
[out] Byte array to be filled with random values.
nBytes
[in] Long specifying the number of required bytes in the nonce.

C/C++ Syntax

long _stdcall RNG_NonceData(unsigned char *bytearray, long nbytes);

Returns (VB6/C)

Long: If successful, the return value is 0; otherwise it returns a non-zero error code.

.NET Equivalent

Rng.NonceBytes Method

Remarks

The array abOutput must be at least nBytes bytes long. Note the (0) in abOutput(0) for VB6.

Example

This example generates three nonces each 8 bytes long.

    Dim abKey() As Byte
    Dim nRet As Long
    Dim nKeyBytes As Long
    Dim i As Integer
    
    nKeyBytes = 8
    ReDim abKey(nKeyBytes - 1)
    ' Generate three successive 8-byte nonces
    For i = 1 To 3
        nRet = RNG_NonceData(abKey(0), nKeyBytes)
        Debug.Print cnvHexStrFromBytes(abKey)
    Next

See Also

RNG_NonceDataHex RNG_Number RNG_KeyBytes

[Contents] [Index]

[HOME]   [NEXT: RNG_NonceDataHex...]

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