CryptoSys PKI examples VB6 to VB.NET

PWD_PromptEx

Prompts for a password with extra options.

VB6/VBA

Debug.Print "Testing PWD_PromptEx ..."
Dim strPassword As String * 511
Dim nLen As Long

nLen = PWD_PromptEx(strPassword, Len(strPassword), _
    "Demo of PWD_PromptEx", "Type secret phrase:", 0)
' Do something with the password...
If nLen > 0 Then
    Debug.Print "Password entered=" & Left(strPassword, nLen)
ElseIf nLen < 0 Then
    Debug.Print "User cancelled"
Else
    Debug.Print "Empty password entered"
End If
' Clean up
Call WIPE_String(strPassword, nLen)
strPassword = ""

Output

Testing PWD_PromptEx ...
Password entered=password

VB.NET

Console.WriteLine("Testing PWD_PromptEx ...")
Dim strPassword As String

strPassword = Pwd.Prompt(512, "Demo of PWD_PromptEx", "Type secret phrase:")
' Do something with the password...
If strPassword.Length > 0 Then
    Console.WriteLine("Password entered=" & strPassword)
    ''ElseIf nLen < 0 Then
    ''Console.WriteLine("User cancelled")
Else
    Console.WriteLine("Empty password entered or User Cancelled")
End If
' Clean up
''Call WIPE_String(strPassword, nLen)
strPassword = ""

[Contents]

[HOME]   [NEXT: RNG_Bytes...]

Copyright © 2010-20 D.I. Management Services Pty Ltd. All rights reserved.