MailBee.NET Objects 4.0

Smime.EncryptionAlgorithm Property

Gets or sets the algorithm to use for encrypting messages.

public Algorithm EncryptionAlgorithm {get; set;}

Property Value

A reference to Algorithm object representing the algorithm to be used for encrypting messages. The default algorithm is RC4.

Remarks

Usually, there is no need to change the default value of this property.

In order to set this property, the developer can get Algorithm instance using CreateInstanceByOid or CreateInstanceById methods.

Exceptions

Exception TypeCondition
MailBeeInvalidArgumentExceptionvalue is a null reference (Nothing in Visual Basic).

Example

This sample sets DES encryption algorithm if it's supported by the operating system.

[C#]
// To use the code below, import MailBee namespace at the top of your code
using MailBee.Security;

// The actual code (put it into a method of your class)

Smime objSmime = new Smime();
Algorithm[] algs = objSmime.Provider.GetSupportedAlgorithms();
Algorithm algDes = null;

// Iterate through all encryption algorithms supported by CSP
foreach (Algorithm alg in algs)
{
    if (alg.Name.ToLower() == "des")
    {
        algDes = alg;
        break;
    }
}
if (algDes != null)
{
    objSmime.EncryptionAlgorithm = algDes;
}
[Visul Basic]
' To use the code below, import MailBee namespace at the top of your code
Imports MailBee.Security

' The actual code (put it into a method of your class)

Dim objSmime As Smime = New Smime
Dim algs() As Algorithm = objSmime.Provider.GetSupportedAlgorithms()
Dim algDes As Algorithm = Nothing

' Iterate through all encryption algorithms supported by CSP
For Each alg As Algorithm In algs
    If (alg.Name.ToLower() = "des") Then
        algDes = alg
        Exit For
    End If
Next
If (Not IsNothing(algDes)) Then
    objSmime.EncryptionAlgorithm = algDes
End If

See Also

Smime Class | MailBee.Security Namespace | HashAlgorithm | Encrypt