AutoIt
AutoIt
Load PEM Public/Private Key into RSA Object
See more RSA Examples
Demonstrates how to load a PEM key into the Chilkat RSA object.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oRsa = ObjCreate("Chilkat.Rsa")
; First demonstrate importing a PEM public key:
Local $sPublicKeyPem = "PEM public-key data goes here"
$oPubkey = ObjCreate("Chilkat.PublicKey")
$bSuccess = $oPubkey.LoadFromString($sPublicKeyPem)
If ($bSuccess = False) Then
ConsoleWrite($oPubkey.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oRsa.UsePublicKey($oPubkey)
If ($bSuccess = False) Then
ConsoleWrite($oRsa.LastErrorText & @CRLF)
Exit
EndIf
; Demonstrate importing a PEM private key:
Local $sPrivateKeyPem = "PEM private-key data goes here"
$oPrivkey = ObjCreate("Chilkat.PrivateKey")
; If the private key PEM is protected with a password, then
; call LoadEncryptedPem. Otherwise call LoadPem.
$bSuccess = $oPrivkey.LoadPem($sPrivateKeyPem)
If ($bSuccess = False) Then
ConsoleWrite($oPrivkey.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oRsa.UsePrivateKey($oPrivkey)
If ($bSuccess = False) Then
ConsoleWrite($oRsa.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("OK!" & @CRLF)