(AutoIt) Convert DSA DER Private Key to PEM
Converts a DSA private key from DER format to PEM. Demonstrates how to write both encrypted and unencrypted PEM formatted private keys.
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oDsa = ObjCreate("Chilkat.Dsa")
; Load a DER private key.
Local $bSuccess = $oDsa.FromDerFile("dsa_priv.der")
If ($bSuccess <> True) Then
ConsoleWrite($oDsa.LastErrorText & @CRLF)
Exit
EndIf
Local $sPemStr
; Save to unencrypted PEM:
$sPemStr = $oDsa.ToPem()
$bSuccess = $oDsa.SaveText($sPemStr,"dsa_priv.pem")
If ($bSuccess <> True) Then
ConsoleWrite($oDsa.LastErrorText & @CRLF)
Exit
EndIf
; Save to encrypted PEM:
$sPemStr = $oDsa.ToEncryptedPem("myPassword")
$bSuccess = $oDsa.SaveText($sPemStr,"dsa_privEncrypted.pem")
If ($bSuccess <> True) Then
ConsoleWrite($oDsa.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Finished!" & @CRLF)
|