Sample code for 30+ languages & platforms
AutoIt

RSA Sign using Base64 Private Key

See more RSA Examples

Signs a string using a non-encrypted RSA private key in base64 encoding. Returns the RSA signature as a base64 string.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oPrivKey = ObjCreate("Chilkat.PrivateKey")

$oSbPem = ObjCreate("Chilkat.StringBuilder")
$oSbPem.AppendLine("-----BEGIN RSA PRIVATE KEY-----",True)
$oSbPem.AppendLine("MIIC .... j5A==",True)
$oSbPem.AppendLine("-----END RSA PRIVATE KEY-----",True)

$bSuccess = $oPrivKey.LoadPem($oSbPem.GetAsString())
If ($bSuccess = False) Then
    ConsoleWrite($oPrivKey.LastErrorText & @CRLF)
    Exit
EndIf

$oRsa = ObjCreate("Chilkat.Rsa")

$bSuccess = $oRsa.UsePrivateKey($oPrivKey)
If ($bSuccess = False) Then
    ConsoleWrite($oRsa.LastErrorText & @CRLF)
    Exit
EndIf

$oBd = ObjCreate("Chilkat.BinData")
$oBd.AppendString("12345678","utf-8")

$bSuccess = $oRsa.SignRawBd($oBd)
If ($bSuccess = False) Then
    ConsoleWrite($oRsa.LastErrorText & @CRLF)
    Exit
EndIf

; Get the base64 RSA signature.
ConsoleWrite($oBd.GetEncoded("base64") & @CRLF)

$bSuccess = $oRsa.VerifyRawBd($oBd)
If ($bSuccess = False) Then
    ConsoleWrite($oRsa.LastErrorText & @CRLF)
    Exit
EndIf

Local $strOriginal = $oBd.GetString("utf-8")
ConsoleWrite($strOriginal & @CRLF)