AutoIt Requires Chilkat v11.0.0+
AutoIt
Encrypt with RSA-OAEP and AES-128-CBC
See more Email Object Examples
Use this profile when the receiver requires AES-128-CBC content encryption and RSA-OAEP with SHA-256. The SHA-256 settings apply to OAEP and its mask generation function. Use the matching decryption example to inspect the result.
Chilkat AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$oEmail = ObjCreate("Chilkat.Email")
$bSuccess = $oEmail.LoadEml("message.eml")
If ($bSuccess <> True) Then
ConsoleWrite($oEmail.LastErrorText & @CRLF)
Exit
EndIf
; Use the recipient's public encryption certificate. Its private key stays with the recipient.
$oCert = ObjCreate("Chilkat.Cert")
$bSuccess = $oCert.LoadFromFile("recipient.cer")
If ($bSuccess <> True) Then
ConsoleWrite($oCert.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oEmail.SetEncryptCert($oCert)
If ($bSuccess <> True) Then
ConsoleWrite($oEmail.LastErrorText & @CRLF)
Exit
EndIf
$oEmail.Pkcs7CryptAlg = "aes"
$oEmail.Pkcs7KeyLength = 128
$oEmail.OaepPadding = True
$oEmail.OaepHash = "sha256"
$oEmail.OaepMgfHash = "sha256"
$oEmail.SendEncrypted = True
$oMail = ObjCreate("Chilkat.MailMan")
$oRendered = ObjCreate("Chilkat.BinData")
$bSuccess = $oMail.RenderToMimeBd($oEmail,$oRendered)
If ($bSuccess <> True) Then
ConsoleWrite($oMail.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oRendered.WriteFile("oaep-encrypted.eml")
If ($bSuccess <> True) Then
ConsoleWrite("Failed: rendered.WriteFile." & @CRLF)
Exit
EndIf
ConsoleWrite("Saved oaep-encrypted.eml." & @CRLF)