DataFlex
DataFlex
Select the Hash Algorithm for Signed Email
See more Email Object Examples
Demonstrates the Chilkat Email.SigningHashAlg property, which selects the underlying hash algorithm used when sending signed (PKCS#7) email. Possible values are sha1, sha256, sha384, sha512, md5, and md2; the default is sha1. It controls the message-digest algorithm placed in the signature and is used only when a signed message is generated. This example selects SHA-256.
Background: A digital signature does not sign the whole message directly — it signs a hash, a short fixed-length fingerprint computed from the content. The hash algorithm's job is to make it infeasible to find two different messages with the same fingerprint. Older algorithms like
md5 and sha1 are now considered weak (collisions have been demonstrated), so modern signing should prefer sha256 or stronger even though sha1 remains the historical default.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
String sTemp1
// Demonstrates the Email.SigningHashAlg property, which selects the hash (message-digest)
// algorithm used when sending signed (PKCS#7) email. Possible values: sha1, sha256,
// sha384, sha512, md5, md2. The default is sha1.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
// Select SHA-256 for the signature's message digest.
Set ComSigningHashAlg Of hoEmail To "sha256"
Get ComSigningHashAlg Of hoEmail To sTemp1
Showln "SigningHashAlg = " sTemp1
End_Procedure