Generates a random set of byte data suitable for cryptographic keys with a prompt for the user to enter random keystrokes and mouse movements.
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)
long __stdcall RNG_BytesWithPrompt(unsigned char *lpOutput, long nOutBytes, const char *szPrompt, long nOptions);
If successful, the return value is zero. If the parameters are invalid, it returns a negative error code.
Rng.BytesWithPrompt Method (Int32, Rng.Strength)
Rng.BytesWithPrompt Method (Int32, String, Rng.Strength)
static Rng.bytes_with_prompt(n, strength=Strength.BITS_112, prompt='')
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.
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)