

LWordArray(lWordCount) = lWordArray(lWordCount) Or LShift(Asc(Mid(sMessage, lByteCount + 1, 1)), lBytePosition)
#MD5 ENCODING FUNCTION IN VBA MOD#
LBytePosition = (lByteCount Mod BYTES_TO_A_WORD) * BITS_TO_A_BYTE LWordCount = lByteCount \ BYTES_TO_A_WORD LNumberOfWords = (((lMessageLength + ((MODULUS_BITS - CONGRUENT_BITS) \ BITS_TO_A_BYTE)) \ (MODULUS_BITS \ BITS_TO_A_BYTE)) + 1) * (MODULUS_BITS \ BITS_TO_A_WORD) Private Function ConvertToWordArray(sMessage) LResult = lResult Xor &H40000000 Xor lX8 Xor lY8Ī = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac))Ī = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac))Ī = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac))Ī = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)) LResult = lResult Xor &HC0000000 Xor lX8 Xor lY8 LResult = lResult Xor &H80000000 Xor lX8 Xor lY8 LResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF) RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 - iShiftBits))

Private Function RotateLeft(lValue, iShiftBits) RShift = (lValue And &H7FFFFFFE) \ m_l2Power(iShiftBits) Private Function RShift(lValue, iShiftBits) LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits)) LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000

If (lValue And m_l2Power(31 - iShiftBits)) Then Public Function LShift(lValue, iShiftBits) I am no expert on VB and am at a loss as to what is wrong. I have downloaded some VB code and pasted it into a VBA Project module (Module1), but when I enter =MD5(A1) in a cell, it retuns #REF! I'm trying to have a function that returns the MD5# of a cell, e.g.
