DataFlex
DataFlex
Password-Encrypt an Email with AES
See more Email Object Examples
Demonstrates the Chilkat Email.AesEncrypt method, which encrypts the email body, all alternative bodies, all message sub-parts, and attachments using 128-bit AES CBC encryption. This is symmetric, password-based encryption — it does not use certificates or private keys. To decrypt, call AesDecrypt with the same password. Both the sending and receiving applications must use Chilkat and must know the shared password. This example encrypts an email.
Background: This is a Chilkat-specific convenience, distinct from standard S/MIME. Symmetric encryption means one shared secret (the password) both locks and unlocks the message — simple, but it requires a secure way to share that password out-of-band, and only Chilkat-based software can read the result. S/MIME (
SendEncrypted), by contrast, uses public-key certificates and interoperates with standard mail clients. Choose AES password encryption for Chilkat-to-Chilkat exchanges where distributing a shared password is practical.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
Boolean iSuccess
String sTemp1
// Demonstrates the AesEncrypt method, which encrypts the email body, all alternative
// bodies, all sub-parts, and attachments using 128-bit AES CBC encryption with a password.
// This is symmetric, password-based encryption -- it does not use certificates. Both the
// sending and receiving applications must use Chilkat and know the same password.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Confidential"
Set ComBody Of hoEmail To "This body will be AES-encrypted with a password."
// Encrypt the entire email using a shared password.
Get ComAesEncrypt Of hoEmail "secret_password" To iSuccess
// The email content is now encrypted. Call AesDecrypt with the same password to restore it.
Get ComGetMime Of hoEmail To sTemp1
Showln sTemp1
End_Procedure