Adds an array of bytes to the digest.
Public Declare Function MD5_AddBytes Lib "diCryptoSys.dll"
(ByVal hContext As Long, ByRef lpData As Byte, ByVal nDataLen As Long) As Long
nRet = MD5_AddBytes(hContext, abData(0), nDataLen)
long __stdcall MD5_AddBytes(long hContext, const unsigned char *lpData, long nDataLen);
If successful, the return value is 0; otherwise it returns a non-zero error code.
Md5.AddData Method (Byte[])
The handle to the context hContext must have been set up with a
prior call to MD5_Init. This function may be called many times before creating
the final message digest with MD5_HexDigest.
MD5_AddString may also be called.
This example creates the hash of the three-character string "abc" using a mixture of calls
to MD5_AddBytes and MD5_AddString.
Dim nRet As Long
Dim strDigest As String
Dim hContext As Long
Dim abData(2) As Byte
' Set context handle
hContext = MD5_Init()
' Remember to check for an invalid handle
If hContext = 0 Then
MsgBox "Failed to set context"
Exit Function
End If
' Set up a test array of bytes
abData(0) = Asc("a")
abData(1) = &H62 ' same as Asc("b")
' Add mixture of bytes and strings
nRet = MD5_AddBytes(hContext, abData(0), 2)
nRet = MD5_AddString(hContext, "c")
' Set strDigest to be 32 chars
strDigest = String(32, " ")
nRet = MD5_HexDigest(strDigest, hContext)
Debug.Print strDigest
This should result in output as follows:
900150983cd24fb0d6963f7d28e17f72
MD5_Init
MD5_AddString
MD5_HexDigest
MD5_Reset