GetMD5Digest Method


Returns MD5 irreversible digest for the specified text.

Source text can be any string (including null or zero-length string). The method converts the string into bytes and then calculates the digest. The returned digest is guaranteed to be 32 characters length alphanumeric sequence (such as "706138b31d04788a2be339c4ede89f2f"). Each pair of characters ("70", "61", "38", "b3", "1d", etc.) indicates hexadecimal presentation of a byte.

You may use this digest for any purpose (such as encoding passwords). MailBee itself uses MD5 digests to generate name for the message directory created by GetBodyWithEmbeddedObjects and GetBodyWithEmbeddedObjectsEx methods. Corresponding message-id (Message.MessageID property) is used as a source text to calculate digest for.

The message directory path = Temporary directory path + "\" + GetMD5Digest(Message-ID).

The sample code below shows how MailBee creates name for the message directory.


strDigest = ObjectName.GetMD5Digest(Text, [Codepage])  
Parameters:  
Text As String String to get MD5 digest for  
Codepage As Long (optional) The codepage to use to convert text to bytes. The default value is 65001 (corresponds to UTF-8 charset).  
Return value As String MD5 digest of the specified string  

Usage example:

' VB-only sample (see ASP tutorial for ASP samples)

Dim Mailer, Msg

Set Mailer = CreateObject("MailBee.POP3")
Mailer.LicenseKey = "put your license key here"
Mailer.Connect "mailserver.com", 110, "MyName", "MyPassword"
If Mailer.Connected Then
  If Mailer.MessageCount > 0 Then
    Set Msg = Mailer.RetrieveSingleMessage(1)

    ' The next two lines are equivalents: they cause the same message directory to be created
    Msg.GetBodyWithEmbeddedObjects
    Msg.GetBodyWithEmbeddedObjects , Msg.GetMD5Digest(Msg.MessageID)

    MsgBox Msg.GetMessageDirectoryPath
    Msg.RemoveMessageDirectory
  End If
  Mailer.Disconnect
End If

See Also:

GetMD5DigestOfArray Method
GetBodyWithEmbeddedObjects Method
GetBodyWithEmbeddedObjectsEx Method
RemoveMessageDirectory Method
GetMessageDirectoryPath Method


Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.