AutoIt
AutoIt
Validate a Smartcard PIN
See more Certificates Examples
Validates a smartcard PIN. This example only runs on Windows and requires Chilkat v9.5.0.77 or greater.Chilkat AutoIt Downloads
Local $bSuccess = False
; Note: Requires Chilkat v9.5.0.77 or greater.
$oCert = ObjCreate("Chilkat.Cert")
$oCert.SmartCardPin = "000000"
; Load the certificate on the smartcard currently in the reader (or on the USB token).
; Pass an empty string to allow Chilkat to automatically choose the CSP (Cryptographi Service Provider).
; See Load Certificate on Smartcard for information about explicitly selecting a particular CSP.
$bSuccess = $oCert.LoadFromSmartcard("")
If ($bSuccess <> True) Then
ConsoleWrite($oCert.LastErrorText & @CRLF)
Exit
EndIf
; Check to see if the SmartCardPin property contains the valid PIN for the smartcard.
Local $iPinValid = $oCert.CheckSmartCardPin()
If ($iPinValid < 0) Then
ConsoleWrite("Unable to check the PIN validity." & @CRLF)
ConsoleWrite($oCert.LastErrorText & @CRLF)
Exit
EndIf
If ($iPinValid = 1) Then
ConsoleWrite("PIN is valid." & @CRLF)
Else
ConsoleWrite("PIN is invalid." & @CRLF)
EndIf