Private Sub MyButton_Click()
Dim Context As MD2_Context
Dim Digest As MD2_Digest
Dim MyStrData As String
MyStrData = "Hello World!"
Dim nLen As Long
nLen = Len(MyStrData)
'Convert the string to byte array
Dim MyBinData() As Byte
ReDim MyBinData(1 To nLen)
For i = 1 To nLen
MyBinData(i) = Asc(Mid(MyStrData, i, 1))
Next i
'Initialize the context
MD2_Init Context
'Update the context with first part
Dim nFirstLen As Long
nFirstLen = nLen / 3
MD2_Update Context, MyBinData(1), nFirstLen
'Update the context with second part
MD2_Update Context, MyBinData(nFirstLen + 1), nLen - nFirstLen
'Get the digest
MD2_Final Context, Digest
'Show the hexadecimal representation of the digest
MsgBox QHASH_ConvertToHex(Digest.Value(0), MD2_DIGESTSIZE, True)
End Sub
|