Persits Software, Inc. Knowledge Base Articles

HOWTO: Sending secure mail encrypted with 168-bit Triple-DES

Problem Summary

This article explains how to send secure mail encrypted with the 168-bit Triple-DES cipher as opposed to 40-bit RC2 using AspEncrypt and AspEmail.

Solution

The following code snippet (taken from the AspEncrypt.com web site) sends 40-bit encrypted email:

<%
Set CM = Server.CreateObject("Persits.CryptoManager")
Set Mail = Server.CreateObject("Persits.MailSender")
Set Context = CM.OpenContext("mycontainer", True )
Set RecipientCert = CM.ImportCertFromFile("d:\his.cer")

Set Msg = Context.CreateMessage
Msg.AddRecipientCert RecipientCert

' Send Encrypted Message
Mail.Host = "smtp.veryhotcakes.com"
Mail.Subject = "Encrypted message"
Mail.From = "sales@veryhotcakes.com"
Mail.FromName = "Very Hot Cakes, Inc."
Mail.AddAddress "jsmith@somecompany.com"
Mail.Body = "Here is your receipt."
Mail.SendEncrypted Msg
' Use CryptoMessage object
%>

To change the cipher from 40-bit RC2 to 168-bit Triple-DES, pass True to the CreateMessage method, as follows:

<%
...
Set Msg = Context.CreateMessage( True )
...
%>

Note that the use of the Triple-DES algorithm requires the Microsoft Enhanced Cryptographic provider, otherwise the error "Invalid algorithm specified" will be thrown. See the following article for details on how to install and configure the necessary cryptographic provider.

PS01032928 - Invalid flags specified/Invalid algorithm specified error when using strong encryption