Adds an array of bytes to the digest.
VB6/VBA
Debug.Print "Testing MD5_AddBytes ..." 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 Sub 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
Output
Testing MD5_AddBytes ... 900150983cd24fb0d6963f7d28e17f72
VB.NET
Console.WriteLine("Testing MD5_AddBytes ...") ''Dim nRet As Integer Dim strDigest As String ''Dim hContext As Integer Dim abData(1) As Byte Dim fIsOK As Boolean Dim oMd5 As Md5 = Md5.Instance() fIsOK = oMd5.Init() If Not fIsOK Then MsgBox("Failed to set context") Exit Sub 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 oMd5.AddData(abData) oMd5.AddData("c") ' Set strDigest to be 32 chars ''strDigest = String(32, " ") strDigest = oMd5.HexDigest() Console.WriteLine(strDigest)
[Contents]