SignatureHashAlgorithmType Enumeration


Provides enumered values for e-mail digital signature algorithm. SHA256 is recommended.

[Visual Basic]
Public Enum SignatureHashAlgorithmType
[C#]
public enum SignatureHashAlgorithmType
[C++]
__value public enum SignatureHashAlgorithmType
[JScript]
public enum SignatureHashAlgorithmType

Members

Members name Description
SHA1 Uses RSA\SHA1 hash algorithm.
SHA256 Uses RSA\SHA256 hash algorithm.
SHA384 Uses RSA\SHA384 hash algorithm.
SHA512 Uses RSA\SHA512 hash algorithm.
MD5 Uses RSA\MD5 hash algorithm.

Example

[Visual Basic, C#] The following example demonstrates how to load certificate to sign email content with EASendMail SMTP Component. To get the full samples of EASendMail, please refer to Samples section.

[VB - Sign Email with Certificate]

Try
    Dim oMail As SmtpMail = New SmtpMail("TryIt")
    oMail.From = New MailAddress("test@emailarchitect.net")

    ' Find certificate by email adddress in My Personal Store. 
    ' The certificate can be imported by *.pfx file like this: 
    ' oMail.From.Certificate.Load("c:\test.pfx", "pfxpassword", Certificate.CertificateKeyLocation.CRYPT_USER_KEYSET) 
    ' Once the certificate is loaded to From, the email content will be signed automatically

    oMail.From.Certificate.FindSubject(oMail.From.Address,
        Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER,
        "My")

    ' Use sha256 hash algorithm 
    oMail.SignatureHashAlgorithm = SignatureHashAlgorithmType.SHA256
Catch exp As Exception
    Console.WriteLine("No sign certificate found for sender email: {0}", exp.Message)
End Try


[C# - Sign Email with Certificate] try { SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = "test@adminsystem.com"; // Find certificate by email adddress in My Personal Store. // The certificate can be also imported by *.pfx file like this: // oMail.From.Certificate.Load("c:\\test.pfx", "pfxpassword", Certificate.CertificateKeyLocation.CRYPT_USER_KEYSET); // Once the certificate is loaded to From, the email content will be signed automatically oMail.From.Certificate.FindSubject(oMail.From.Address, Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER, "My"); // Use sha256 hash algorithm oMail.SignatureHashAlgorithm = SignatureHashAlgorithmType.SHA256; } catch (Exception exp) { Console.WriteLine("No sign certificate found {0}", exp.Message); }

Signature Algorithm

You can use SignatureHashAlgorithm property to set signature algorithm to MD5, SHA1, SHA256, SHA384 or SHA512.

RSASSA-PSS Signature

If you need to use RSASSA-PSS signature scheme, you need a special version of EASendMail, please have a look at this topic:
RSASSA-PSS + RSA-OAEP Encryption with SHA256

See Also

SmtpMail.SignatureHashAlgorithm Property
SmtpMail.EncryptionAlgorithm Property
Digital Signature and E-mail Encryption
MailAddress.Certificate Property