1 2 3 4 5 6 7 8 9 10 11 12 13
|
Private Function MD5(ByVal StrText As String) As String
On Error Resume Next
Dim hProv As Long, phHash As Long, pdwDataLen As Long, pbData() As Byte
Call CryptAcquireContext(hProv, vbNullString, vbNullString, 1, &HF0000000)
Call CryptCreateHash(hProv, 32768 Or 0 Or 3, 0, 0, phHash)
Call CryptHashData(phHash, ByVal StrText, Len(StrText), 0)
Call CryptGetHashParam(phHash, 4, pdwDataLen, 4, 0)
ReDim pbData(0 To pdwDataLen - 1)
Call CryptGetHashParam(phHash, 2, pbData(0), pdwDataLen, 0)
MD5 = StrConv(pbData, vbUnicode)
CryptDestroyHash phHash
CryptReleaseContext hProv, 0
End Function
|