Gets or sets the hash algorithm to use for signing messages with a digital signature.
A reference to Algorithm object representing the hash algorithm to be used for signing messages. The default algorithm is SHA1.
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.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | value is a null reference (Nothing in Visual Basic). |
This sample sets MD5 hash 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 algHash = null; // Iterate through all hash algorithms supported by OS foreach (Algorithm alg in algs) { if (alg.Name.ToLower() == "md5") { algHash = alg; break; } } if (algHash != null) { objSmime.HashAlgorithm = algHash; }
[Visual 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 algHash As Algorithm = Nothing ' Iterate through all hash algorithms supported by OS For Each alg As Algorithm In algs If (alg.Name.ToLower() = "md5") Then algHash = alg Exit For End If Next If (Not IsNothing(algHash)) Then objSmime.HashAlgorithm = algHash End If
Smime Class | MailBee.Security Namespace | Sign