Sample code for 30+ languages & platforms
AutoIt

Convert DSA DER Private Key to PEM

See more DSA Examples

Converts a DSA private key from DER format to PEM. Demonstrates how to write both encrypted and unencrypted PEM formatted private keys.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; 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.
$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)