CryptoSys PKI Pro Manual

RNG_BytesWithPrompt

Generates a random set of byte data suitable for cryptographic keys with a prompt for the user to enter random keystrokes and mouse movements.

VBA/VB6 Syntax

Public Declare Function RNG_BytesWithPrompt Lib "diCrPKI.dll" (ByRef lpOutput As Byte, ByVal nOutputLen As Long, ByVal strPrompt As String, ByVal nOptions As Long) As Long

nRet = RNG_BytesWithPrompt(lpOutput(0), nOutputLen, strPrompt, nSeedLen)

C/C++ Syntax

long __stdcall RNG_BytesWithPrompt(unsigned char *lpOutput, long nOutBytes, const char *szPrompt, long nOptions);

Parameters

lpOutput
[out] array to receive the random data.
nOutBytes
[in] specifying the required length in bytes.
szPrompt
[in] specifying an (optional) prompt for the dialog. Specify an empty string ("") or NULL to use the default dialog.
nOptions
[in] option flags:
PKI_DEFAULT (0) for default options
PKI_RNG_STRENGTH_112 to make user generate an estimated 112 bits of security (default)
PKI_RNG_STRENGTH_128 to make user generate an estimated 128 bits of security
PKI_RNG_STRENGTH_192 to make user generate an estimated 192 bits of security
PKI_RNG_STRENGTH_256 to make user generate an estimated 256 bits of security

Returns (VBA/C)

If successful, the return value is zero. If the parameters are invalid, it returns a negative error code.

.NET Equivalent

Rng.BytesWithPrompt Method (Int32, Rng.Strength)
Rng.BytesWithPrompt Method (Int32, String, Rng.Strength)

Python Equivalent

static Rng.bytes_with_prompt(n, strength=Strength.BITS_112, prompt='')

Remarks

Once started, there is no way to abandon the dialog that prompts the user except by terminating the process. Some applications may not handle the GUI dialog. Make your own tests to check. The maximum number of random bytes that can be requested in one call is 65,536 (64 kB). See Random Number Generator for more information on the RNG and its compliance with the relevant standards.

Example

Dim abData() As Byte
Dim nDataLen As Long

' Allocate byte array for 16 bytes
nDataLen = 16
ReDim abData(nDataLen - 1)

' Default prompt with default 112-bit security strength
Call RNG_BytesWithPrompt(abData(0), nDataLen, "", 0)
Debug.Print cnvHexStrFromBytes(abData)

' User-selected prompt with 128-bit security strength
Call RNG_BytesWithPrompt(abData(0), nDataLen, "Our own prompt: type until done...", PKI_RNG_STRENGTH_128)
Debug.Print cnvHexStrFromBytes(abData)

See Also

RNG_Bytes

[Contents] [Index]

[PREV: RNG_Bytes...]   [Contents]   [Index]   
   [NEXT: RNG_Guid...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-01-01T11:51:59Z.