CryptoSys PKI Pro Manual

RNG_Guid

Generate a random 36-character Global Unique IDentifier (GUID) string.

VBA/VB6 Syntax

Public Declare Function RNG_Guid Lib "diCrPKI.dll" (ByVal strOutput As String, ByVal nOutChars As Long, ByVal nOptions As Long) As Long

nRet = RNG_Guid(strOutput, nOutChars, nOptions)

C/C++ Syntax

long __stdcall RNG_Guid(char *szOutput, long nOutChars, long nOptions);

Parameters

szOutput
[out] String buffer to receive output.
nOutChars
[in] Maximum number of characters to be received.
nOptions
[in] option flags: not used in this release. Specify zero.

Returns (VBA/C)

If successful, the return value is the number of characters in or required for the output string (always 36); otherwise it returns a negative error code.

VBA Wrapper Syntax

Public Function rngGuid() As String

.NET Equivalent

Rng.Guid Method

C++ (STL) Equivalent

static std::string dipki::Rng::Guid ()

Python Equivalent

static Rng.guid()

Remarks

For the "raw" VBA/C function, the user must allocate an output string buffer szOutput of the required length. Specify a zero nOutChars or an empty string for szOutput to find the required length. ANSI C users must add one to this value when allocating memory.

A Global Unique IDentifier (GUID) is also called a version 4 Universally Unique IDentifier (UUID) and is defined in section 4.4 of [RFC4122]. The output is always a 36-character string of the form "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" where 'x' is a hexadecimal digit [0-9a-f]. The constant PKI_RNG_GUID_CHARS equal to 36 is defined for convenience. It is an error (SHORT_BUF_ERROR) if the output buffer is too short.

Example (VBA core function)

Dim strGuid As String
strGuid = String(PKI_RNG_GUID_CHARS, " ")
Call RNG_Guid(strGuid, Len(strGuid), 0)
Debug.Print strGuid

The output will be different each time. For example

9d67804a-4d8f-40c2-8f7d-5f05f90cb228
85291113-b97f-4d30-8892-76d556801372
fc4272a5-c731-4b96-9c7c-450fad9a29c0

Example (VBA wrapper function)

Dim i As Integer
For i = 1 To 5
    Debug.Print rngGuid()
Next

See Also

[Contents] [Index]

[PREV: RNG_BytesWithPrompt...]   [Contents]   [Index]   
   [NEXT: RNG_Initialize...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.