Creates an MD5 message digest in Byte array format from a message in Byte array format.
VB6/VBA
Debug.Print "Testing MD5_BytesHash ..." Dim nRet As Long Dim abData(2) As Byte ' Create 3-byte array (NB zero-based) Dim abDigest(15) As Byte ' Create 16-byte array to receive digest Dim i As Integer ' Setup byte array with "abc" abData(0) = Asc("a") abData(1) = Asc("b") abData(2) = Asc("c") ' Compute MD5 hash digest of input nRet = MD5_BytesHash(abDigest(0), abData(0), 3) ' Now carry out repeated hashes of the 16-byte-long digest For i = 2 To 1000 nRet = MD5_BytesHash(abDigest(0), abDigest(0), 16) Next ' Print H(1000) in hex format Debug.Print cnvHexStrFromBytes(abDigest)
Output
Testing MD5_BytesHash ... 1375514E02C36AAE265B2FE20CCADAFB
VB.NET
Console.WriteLine("Testing MD5_BytesHash ...") ''Dim nRet As Integer Dim abData(2) As Byte ' Create 3-byte array (NB zero-based) ''Dim abDigest(15) As Byte ' Create 16-byte array to receive digest Dim abDigest() As Byte Dim i As Integer ' Setup byte array with "abc" abData(0) = Asc("a") abData(1) = Asc("b") abData(2) = Asc("c") ' Compute MD5 hash digest of input abDigest = Md5.BytesHash(abData) ' Now carry out repeated hashes of the 16-byte-long digest For i = 2 To 1000 abDigest = Md5.BytesHash(abDigest) Next ' Print H(1000) in hex format Console.WriteLine(Cnv.ToHex(abDigest))
[Contents]