Sample code for 30+ languages & platforms
AutoIt

RSA Encrypt with Modulus and Exponent

See more RSA Examples

Demonstrates how to RSA encrypt with a given modulus and exponent.

Chilkat AutoIt Downloads

AutoIt
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")

; Assuming you already have a base64 modulus and exponent,
; wrap it in XML like this:
Local $sModulus = "qMBRpdYrAy5aMmo31NErUizh5sbweguSmh4wlK6uJEIDl+kwTlROnE34KOFExeTbJSX0WygPi+vWl0yNq7buIMUKpytossAAWut5khO3CQJxTk7G2gnEPNUUXHiExGgNrLzcSLv8YIlfVALhoRWyC67KOL+a+3taNq3h+BHeWhM="
Local $sExponent = "AQAB"

$oXml = ObjCreate("Chilkat.Xml")
$oXml.Tag = "RSAPublicKey"
$oXml.NewChild2 "Modulus",$sModulus
$oXml.NewChild2 "Exponent",$sExponent

$oPubKey = ObjCreate("Chilkat.PublicKey")
$bSuccess = $oPubKey.LoadFromString($oXml)
If ($bSuccess = False) Then
    ConsoleWrite($oPubKey.LastErrorText & @CRLF)
    Exit
EndIf

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

Local $bUsePrivateKey = False
Local $sPlainText = "message in a bottle"

$oRsa.EncodingMode = "base64"
Local $sEncryptedStrBase64 = $oRsa.EncryptStringENC($sPlainText,$bUsePrivateKey)
ConsoleWrite($sEncryptedStrBase64 & @CRLF)